Iphone UILocalnotification即使在取消通知后仍会触发
即使在取消通知后,通知仍会触发。我试着检查取消方法,结果证明是正确的 当我取消通知时,通知将在第二天再次触发Iphone UILocalnotification即使在取消通知后仍会触发,iphone,ios,objective-c,uilocalnotification,Iphone,Ios,Objective C,Uilocalnotification,即使在取消通知后,通知仍会触发。我试着检查取消方法,结果证明是正确的 当我取消通知时,通知将在第二天再次触发 - (void)cancelNotification:(int)bookID { NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; NSLog(@"Cancelling... Before %d",[[[UIApplication shared
- (void)cancelNotification:(int)bookID
{
NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
NSLog(@"Cancelling... Before %d",[[[UIApplication sharedApplication]scheduledLocalNotifications]count]);
for (UILocalNotification *notification in notifications)
{
int notifRemedyId = [[notification.userInfo objectForKey:@"kRemindMeNotificationRemedyIDKey"]intValue];
NSLog(@"remedyID : %d",remedyId);
NSLog(@"notifyId : %d",notifRemedyId);
if (remedyId == notifRemedyId)
{
[[UIApplication sharedApplication] cancelLocalNotification:notification];
}
}
}
我认为这是因为repeatInterval。是否应删除repeatInterval属性
所以我想知道我哪里出了问题。1)首先检查检索到的特定通知对象不是零。还要检查这是否是要取消的通知
2)当您确定通知对象不是nil且通知是所需的通知时,请在下面的命令中触发通知是您所需的通知对象
[[UIApplication sharedApplication] cancelLocalNotification:notification];
3)我正在查看您的代码,我可以看到您没有在代码中的任何位置使用bookID
通知。不确定您是否正在使用该代码
4)不,您不需要做任何额外的事情来取消重复通知
注意:请使用最终更新的代码更新您的问题。这看起来很混乱。您不应该使用[[UIApplication sharedApplication]cancelAllLocalNotifications]?记录您的值,看看您得到了什么。@HotLicks我已经解决了问题,我没有存档在viewdidload中取消的通知。因此,如果通知被取消,则应用程序不会得到更新,哪个通知被取消。我添加了计划通知方法哪个方法取消通知?请检查您的
cancelNotification
方法。您在哪里使用bookID
?我没有看到它在任何地方被使用。我把它作为bookID,只是不想发布我的实际代码。只需浏览我提到的所有要点。这应该可以解决问题。