我使用这个Link设置Repeat UILocalNotification并且我的代码运行成功但问题是即使我删除了我的应用程序,也会弹出警报是否有任何方法可以实际取消重复UILocalNotification
这是我用来在1分钟后设置重复UILocalNotification的代码
- (void)alertSelector:(NSString *)AlertTitle WithFiringTime:(NSDate *)date{
UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];
if (!localNotification)
return;
[localNotification setFireDate:date];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
NSDictionary *data = [NSDictionary dictionaryWithObject:date forKey:@"payload"];
[localNotification setUserInfo:data];
[localNotification setAlertBody:AlertTitle];
[localNotification setAlertAction:@"View"];
[localNotification setHasAction:YES];
localNotification.repeatInterval = NSMinuteCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
使用下面的代码我取消了UILocalNotification,但它取消了所有的UILocalNotification,我想只取消1分钟后弹出的UILocalNotification,重复UILocalNotification
[[UIApplication sharedApplication] cancelAllLocalNotifications];
提前谢谢
答案 0 :(得分:0)
您应该保留要在将来某个时间取消的通知,而不是使用cancelAllLocalNotifications
,而是使用cancelNotification:
方法。
cancelNotification:
可让您取消特定通知,但相当明显的警告是您必须保留要取消的通知对象!