From 50f0ba4e3cc41e35c35f1a1a67e89d25bd4ce242 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 17 Mar 2022 19:41:02 +0000 Subject: [PATCH] only setting notification channel for supported android versions --- .../st/notifications/NotificationChannels.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationChannels.kt b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationChannels.kt index 80e49da..676d968 100644 --- a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationChannels.kt +++ b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationChannels.kt @@ -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,14 +11,16 @@ class NotificationChannels( ) { fun initChannels() { - if (notificationManager.getNotificationChannel(channelId) == null) { - notificationManager.createNotificationChannel( - NotificationChannel( - channelId, - "messages", - NotificationManager.IMPORTANCE_HIGH, + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (notificationManager.getNotificationChannel(channelId) == null) { + notificationManager.createNotificationChannel( + NotificationChannel( + channelId, + "messages", + NotificationManager.IMPORTANCE_HIGH, + ) ) - ) + } } }