only setting notification channel for supported android versions
This commit is contained in:
parent
7e82cf1569
commit
50f0ba4e3c
|
@ -2,6 +2,7 @@ package app.dapk.st.notifications
|
||||||
|
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
|
import android.os.Build
|
||||||
|
|
||||||
private const val channelId = "message"
|
private const val channelId = "message"
|
||||||
|
|
||||||
|
@ -10,14 +11,16 @@ class NotificationChannels(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun initChannels() {
|
fun initChannels() {
|
||||||
if (notificationManager.getNotificationChannel(channelId) == null) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
notificationManager.createNotificationChannel(
|
if (notificationManager.getNotificationChannel(channelId) == null) {
|
||||||
NotificationChannel(
|
notificationManager.createNotificationChannel(
|
||||||
channelId,
|
NotificationChannel(
|
||||||
"messages",
|
channelId,
|
||||||
NotificationManager.IMPORTANCE_HIGH,
|
"messages",
|
||||||
|
NotificationManager.IMPORTANCE_HIGH,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue