Skip to content

Instantly share code, notes, and snippets.

@EfeBudak
Created August 15, 2019 07:40
Show Gist options
  • Save EfeBudak/602b7ecef8ccd128b2ebc9b3b29bce4a to your computer and use it in GitHub Desktop.
Save EfeBudak/602b7ecef8ccd128b2ebc9b3b29bce4a to your computer and use it in GitHub Desktop.
Code piece that creates a notification channel on Android
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME, importance).apply {
description = CHANNEL_DESCRIPTION
}
val notificationManager: NotificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment