Skip to content

Commit

Permalink
fix crashing after cancel not existing notification
Browse files Browse the repository at this point in the history
  • Loading branch information
sashkooo committed Nov 22, 2016
1 parent 353714a commit 6affe55
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -140,8 +140,12 @@ public static void CancelNotification(int id)
Activity currentActivity = UnityPlayer.currentActivity;
AlarmManager am = (AlarmManager)currentActivity.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(currentActivity, UnityNotificationManager.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(currentActivity, id, intent, 0);
am.cancel(pendingIntent);
PendingIntent pendingIntent = PendingIntent.getBroadcast(currentActivity, id, intent, PendingIntent.FLAG_NO_CREATE);
if (pendingIntent != null)
{
am.cancel(pendingIntent);
pendingIntent.cancel();
}
}

public static void CancelAll(){
Expand Down

0 comments on commit 6affe55

Please sign in to comment.