Last active
June 13, 2022 17:16
-
-
Save molidev8/66d2eed25e0576b2301c006e46dd127c to your computer and use it in GitHub Desktop.
A function to create a notification channel
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
fun createChannel( | |
context: Context, | |
channelId = CHANNEL_ID, | |
@StringRes channelName: Int, | |
@StringRes channelDescription: Int, | |
importanceLevel: Int = NotificationManager.IMPORTANCE_HIGH | |
) { | |
val channel = NotificationChannel( | |
context.getString(channelId), | |
context.getString(channelName), | |
importanceLevel | |
).apply { | |
description = context.getString(channelDescription) | |
} | |
val notificationManager = | |
context.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