即使从DB(核心数据)中删除要触发的事件,也会触发UILocalNotification

时间:2013-05-31 05:17:39

标签: ios

对于你们中的许多人来说,这可能不是一个难以回答的问题,但是你会告诉我为什么通知被解雇,即使我删除了活动它来自数据库(核心数据)

谢谢,

最诚挚的问候。

3 个答案:

答案 0 :(得分:1)

您必须 cancelLocalNotification 才能停止触发 UILocalNotification

修改

我在这里添加了取消本地通知的方法。你需要保持一个id 每个通知的notification.userInfo(字典)。如果要取消通知,请传递此方法中的通知ID

-(void)cancelNotificationForId:(NSString*)id {

    NSArray *notifs = [[UIApplication sharedApplication]scheduledLocalNotifications];
    for (UILocalNotification *notification in notifs) {
        if ([[notification.userInfo objectForKey:@"alarm_id"] isEqualToString:id]) {
            [[UIApplication sharedApplication] cancelLocalNotification:notification];
        }
    }

} 

试试这个方法

答案 1 :(得分:0)

您需要在通知ID的帮助下删除通知。

答案 2 :(得分:0)

有关user2339310和manujmv的答案中提及的术语的更多参考,请参阅Apple Documentation for Canceling Local Notification。这将清除UILocalNotification的概念并取消。