0

即使在取消后通知也会触发。我尝试检查取消方法,结果证明是正确的。

当我取消通知时,第二天会再次触发通知

- (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.should repeatInterval 属性被删除。

所以我想知道我哪里出错了。

4

1 回答 1

0

1)首先检查检索到的特定通知对象不是nil。还要检查这是否是您要取消的通知。

2)当您确定通知对象不为零并且通知是所需的通知时,请按以下命令触发。notification是你想要的通知对象。

[[UIApplication sharedApplication] cancelLocalNotification:notification];

3)我正在查看您的代码,我可以看到您没有bookID在代码中的任何地方使用通知。不确定您是否正在使用该代码。

4)不,你不需要做任何额外的事情来取消重复通知

注意:请使用最终更新的代码更新您的问题。这看起来令人困惑。

于 2013-05-13T01:22:31.960 回答