1

我试着做NSLog(@"The notifications is \n %@",notification);

日志消息是:2013-10-18 12:23:36.010 Remainder[2433:207] 通知是 {fire date = (null), time zone = Asia/Kolkata (IST) offset 19800, repeat interval = 0,重复计数 = UILocalNotificationInfiniteRepeatCount,下一个触发日期 = 印度标准时间 2013 年 10 月 18 日星期五下午 12:23:36}

4

3 回答 3

0

用于删除特定通知

[[UIApplication sharedApplication] cancelLocalNotification: notification];

并取消所有通知

[[UIApplication sharedApplication] cancelAllLocalNotifications];
于 2013-10-25T06:07:59.833 回答
0

您必须删除特定的预定通知,您必须使用以下方法。

[[UIApplication sharedApplication] cancelLocalNotification: 通知];
于 2013-10-25T06:15:21.660 回答
0

如果返回 null,则不返回通知。所以试试这个

方法1:

-(void) scheduleNotificationForDate:(NSDate *)date AlertBody:(NSString *)alertBody ActionButtonTitle:(NSString *)actionButtonTitle NotificationID:(NSString *)notificationID{

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = date;
    localNotification.timeZone = [NSTimeZone localTimeZone];
    localNotification.alertBody = alertBody;
    localNotification.alertAction = actionButtonTitle;
    localNotification.soundName = @"yourSound.wav";

    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:notificationID forKey:notificationID];
    localNotification.userInfo = infoDict;

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

方法2:

设置通知后,编辑它的唯一方法是取消旧通知并重新创建另一个通知,因此您可以这样做,搜索现有通知并取消它。

`for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications]) 
{
        if([[aNotif.userInfo objectForKey:@"id"] isEqualToString:nId])
 {
            [[UIApplication sharedApplication]cancelLocalNotification:aNotif];
        }
    }`
于 2013-10-25T06:16:08.083 回答