Created
July 22, 2017 04:19
-
-
Save elsennov/63993ed824d03763e603d8ae36d7afe1 to your computer and use it in GitHub Desktop.
Hotline Initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun initHotline(applicationContext: Context) { | |
initHotlineBaseConfig(applicationContext) | |
initHotlineNotification(applicationContext) | |
initHotlineUser(applicationContext) | |
} | |
private fun initHotlineBaseConfig(applicationContext: Context) { | |
val hotlineConfig = HotlineConfig(BuildConfig.HOTLINE_APP_ID, BuildConfig.HOTLINE_APP_KEY) | |
Hotline.getInstance(applicationContext).init(hotlineConfig) | |
} | |
private fun initHotlineNotification(applicationContext: Context) { | |
val notificationConfig = HotlineNotificationConfig() | |
.setNotificationSoundEnabled(true) | |
.setSmallIcon(R.drawable.ic_notification) | |
.setLargeIcon(R.mipmap.ic_launcher) | |
.launchDeepLinkTargetOnNotificationClick(true) | |
.launchActivityOnFinish(LoginActivity::class.java.name) | |
.setPriority(NotificationCompat.PRIORITY_HIGH) | |
Hotline.getInstance(applicationContext).setNotificationConfig(notificationConfig) | |
} | |
private fun initHotlineUser(applicationContext: Context) { | |
// Get current user | |
val user = localRequestManager.getUser() | |
// Get the user object for the current installation | |
val hotlineUser = Hotline.getInstance(applicationContext).user | |
// Apply current user | |
hotlineUser.name = user.name | |
hotlineUser.email = user.email | |
hotlineUser.externalId = user.id | |
// Call updateUser so that the user information is synced with Hotline's servers | |
Hotline.getInstance(applicationContext).updateUser(hotlineUser) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment