Skip to content

Instantly share code, notes, and snippets.

@s3va
Created September 30, 2021 19:23
Show Gist options
  • Save s3va/b60cb6a2f327ee1962825b7e8f245e81 to your computer and use it in GitHub Desktop.
Save s3va/b60cb6a2f327ee1962825b7e8f245e81 to your computer and use it in GitHub Desktop.
NotificationChannel
private const val CHANNEL_ID = "default_channel_id"
private const val CHANNEL_NAME = "default_channel_name"
private const val CHANNEL_DESC = "default channel description"
class TakeMyApp: Application() {
override fun onCreate() {
super.onCreate()
createNotificationChannel()
}
fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val notificationChannel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME,
android.app.NotificationManager.IMPORTANCE_DEFAULT)
notificationChannel.description= CHANNEL_DESC
(getSystemService(NOTIFICATION_SERVICE) as NotificationManager)
.createNotificationChannel(notificationChannel)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment