Skip to content

Instantly share code, notes, and snippets.

@elsennov
Created July 22, 2017 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elsennov/63993ed824d03763e603d8ae36d7afe1 to your computer and use it in GitHub Desktop.
Save elsennov/63993ed824d03763e603d8ae36d7afe1 to your computer and use it in GitHub Desktop.
Hotline Initialization
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