Created
September 30, 2021 19:23
-
-
Save s3va/b60cb6a2f327ee1962825b7e8f245e81 to your computer and use it in GitHub Desktop.
NotificationChannel
This file contains 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 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