Created
August 15, 2019 07:40
-
-
Save EfeBudak/602b7ecef8ccd128b2ebc9b3b29bce4a to your computer and use it in GitHub Desktop.
Code piece that creates a notification channel on Android
This file contains hidden or 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
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