Bimba.git

ref: ef9c50aed3aab8d733a725c2aeb539cba7d3880e

app/src/main/java/ml/adamsprogs/bimba/NotificationChannels.kt


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package ml.adamsprogs.bimba

import android.app.NotificationChannel
import android.app.NotificationManager
import android.os.Build
import androidx.annotation.RequiresApi


class NotificationChannels {
    companion object {
        const val CHANNEL_UPDATES = "updates"

        @RequiresApi(Build.VERSION_CODES.O)
        fun makeChannel(id: String, name: String, manager: NotificationManager) {
            try {
                manager.getNotificationChannel(id)
            } catch (e: RuntimeException) {
                val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_MIN)
                channel.enableLights(false)
                channel.enableVibration(false)
                channel.setShowBadge(false)
                manager.createNotificationChannel(channel)
            }
        }
    }
}