繁体   English   中英

UILocalnotification即使在取消通知后也会触发

[英]UILocalnotification firing even after notification is cancelled

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

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

- (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)首先检查检索到的特定通知对象不是nil 还要检查这是否是您要取消的通知。

2)当您确定通知对象不是nil并且通知是所需的通知时,请在命令下方执行。 notification是您所需的通知对象。

[[UIApplication sharedApplication] cancelLocalNotification:notification];

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

4)不,您无需执行任何其他操作即可取消重复通知

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM