Skip to content

Commit 8f5df4d

Browse files
committed
Cleanup and cancel alarms after showing
1 parent 8b64eb7 commit 8f5df4d

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationManager.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -698,22 +698,17 @@ public void onReceive(Context context, Intent intent) {
698698
// Call the system notification service to notify the notification.
699699
protected static void notify(Context context, int id, Notification notification) {
700700
boolean showInForeground = notification.extras.getBoolean(KEY_SHOW_IN_FOREGROUND, true);
701-
boolean didShowNotification = false;
702701
if (!isInForeground() || showInForeground) {
703-
didShowNotification = true;
704702
getNotificationManager(context).notify(id, notification);
705703
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) synchronized (UnityNotificationManager.class) {
706704
mVisibleNotifications.add(Integer.valueOf(id));
707705
}
708706
}
709707

710-
if (!didShowNotification) {
711-
// if notification is not shown and not repeating, cleanup so it's status does not show as scheduled
712-
long repeatInterval = notification.extras.getLong(KEY_REPEAT_INTERVAL, -1);
713-
if (repeatInterval <= 0) {
714-
mScheduledNotifications.remove(id);
715-
deleteExpiredNotificationIntent(context, String.valueOf(id));
716-
}
708+
long repeatInterval = notification.extras.getLong(KEY_REPEAT_INTERVAL, -1);
709+
if (repeatInterval <= 0) {
710+
mScheduledNotifications.remove(id);
711+
cancelPendingNotificationIntent(context, id);
717712
}
718713

719714
try {

0 commit comments

Comments
 (0)