假设我的应用程序在后台运行,我同时收到2个本地通知。 Alert1 for Notification1显示,然后Alert2 for Notification2显示在Alert1之上。当我点击Alert2的“查看”时,我的应用程序进入前台,并且为Notification2调用didReceiveLocalNotification
,一切都很好。
但是,Alert1仍然显示(因为它从未关闭或查看过)。如果我点击“查看”,没有任何事情发生,正如预期的那样,Notification1的didReceiveLocalNotification
未被调用。
有没有办法:
didReceiveLocalNotification
未被调用谢谢!
答案 0 :(得分:2)
即使通知已被解雇,调用cancelAllLocalNotifications
也会解除当前显示的提醒。
在Local and Push Notification Programming Guide中提及:
您可以取消特定的预定时间 通过电话通知 cancelLocalNotification:on 应用程序对象,您可以取消 通过调用所有预定通知 cancelAllLocalNotifications。两者的 这些方法也是以编程方式 解雇当前显示的 通知提醒。
因此,我需要cancelAllNotifications
并重新安排我当前的预定通知。我尝试了cancelLocalNotification
,但我没有对通知的引用,因为它已经在scheduledLocalNotifications
数组中不再存在,因为它已经被触发了。