Skip to content

Instantly share code, notes, and snippets.

@victorbrndls
Created June 8, 2021 23:19
Show Gist options
  • Save victorbrndls/96b02353e8bf827bff0188c30087f5ac to your computer and use it in GitHub Desktop.
Save victorbrndls/96b02353e8bf827bff0188c30087f5ac to your computer and use it in GitHub Desktop.
private const val CHANNEL_ID = "heads_up_alerts"
private const val CHANNEL_NAME = "Heads Up Alerts"
private val notificationManager = NotificationManagerCompat.from(context)
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
val channel = NotificationChannel(
CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH
).apply {
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
}
notificationManager.createNotificationChannel(channel)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment