Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Prevent notification crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Aug 21, 2023
1 parent 23d262d commit 3993dc9
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ class NotificationService(
notification: NotificationCompat.Builder,
notificationId: Int
) {
val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
?: return
// Register the channel with the system
val channel = (notification as IvyNotification).ivyChannel.create(context)
try {
val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
?: return
// Register the channel with the system
val channel = (notification as IvyNotification).ivyChannel.create(context)

notificationManager.createNotificationChannel(channel)
notificationManager.notify(notificationId, notification.build())
notificationManager.createNotificationChannel(channel)
notificationManager.notify(notificationId, notification.build())
} catch (e: Exception) {
e.printStackTrace()
}
}

fun dismissNotification(notificationId: Int) {
Expand Down

0 comments on commit 3993dc9

Please sign in to comment.