only setting notification channel for supported android versions

This commit is contained in:
Adam Brown 2022-03-17 19:41:02 +00:00
parent 7e82cf1569
commit 50f0ba4e3c
1 changed files with 10 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package app.dapk.st.notifications
import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Build
private const val channelId = "message"
@ -10,6 +11,7 @@ class NotificationChannels(
) {
fun initChannels() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (notificationManager.getNotificationChannel(channelId) == null) {
notificationManager.createNotificationChannel(
NotificationChannel(
@ -20,5 +22,6 @@ class NotificationChannels(
)
}
}
}
}