NotificationChannels.kt 825 B

1234567891011121314151617181920212223242526
  1. package ml.adamsprogs.bimba
  2. import android.app.NotificationChannel
  3. import android.app.NotificationManager
  4. import android.os.Build
  5. import androidx.annotation.RequiresApi
  6. class NotificationChannels {
  7. companion object {
  8. val CHANNEL_UPDATES = "updates"
  9. @RequiresApi(Build.VERSION_CODES.O)
  10. fun makeChannel(id: String, name: String, manager: NotificationManager) {
  11. try {
  12. manager.getNotificationChannel(id)
  13. } catch (e: RuntimeException) {
  14. val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_MIN)
  15. channel.enableLights(false)
  16. channel.enableVibration(false)
  17. channel.setShowBadge(false)
  18. manager.createNotificationChannel(channel)
  19. }
  20. }
  21. }
  22. }