Created
January 4, 2020 17:09
-
-
Save Lavanyagaur22/fb7da125a9561f8d280ed162f0e0a47e to your computer and use it in GitHub Desktop.
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() { | |
// Create the NotificationChannel, but only on API 26+ because | |
// the NotificationChannel class is new and not in the support library | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
val name = getString(R.string.channel_name) //name of the channel | |
val descriptionText = getString(R.string.channel_description) | |
val importance = NotificationManager.IMPORTANCE_DEFAULT //importance of the channel | |
// Create a NotificationChannel | |
val channel = NotificationChannel(CHANNEL_ID, name, importance).apply { | |
description = descriptionText | |
} | |
// Register the channel with the system, her nm is the NotificationManager object created above. | |
nm.createNotificationChannel(channel) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment