UILocalnotification即使在取消通知后也会触发 [英] UILocalnotification firing even after notification is cancelled

查看:61
本文介绍了UILocalnotification即使在取消通知后也会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The notification is firing even after it is cancelled. I tried checking cancelling method it turned out to be correct.

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

When I cancel a notification, the notification is again fired the next day

- (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属性.

I am thinking its because of repeatInterval.should repeatInterval property be removed.

所以我想知道我要去哪里.

SO I wanted to know where I am going wrong.

推荐答案

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

1) First check retrieved particular notification object is not nil. Also check if that is the notification you want to cancel.

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

2) When you are sure notification object is not nil and the notification is the desired one, then fire below command. notification is your desired notification object.

[[UIApplication sharedApplication] cancelLocalNotification:notification];

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

3) I am looking at your code and I could see that you are not using bookID notification anywhere in your code. Not sure if you are using that code anymore.

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

4) No, you don't need to do anything extra to cancel repeating notification

注意:请使用最终更新的代码来更新您的问题.这看起来很混乱.

Note: Please update your Question with final updated code. This looks confusing.

这篇关于UILocalnotification即使在取消通知后也会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆