1
votes

I tried doing NSLog(@"The notifications is \n %@",notification);

And the log message is : 2013-10-18 12:23:36.010 Remainder[2433:207] The notifications is {fire date = (null), time zone = Asia/Kolkata (IST) offset 19800, repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Friday, October 18, 2013 12:23:36 PM India Standard Time}

3

3 Answers

0
votes

For delete specific notification

[[UIApplication sharedApplication] cancelLocalNotification: notification];

And cancel all notification

[[UIApplication sharedApplication] cancelAllLocalNotifications];
0
votes

you have to delete a particular scheduled notification you have to use the below method.

[[UIApplication sharedApplication] cancelLocalNotification: notification];
0
votes

IF returned null then the notifications are not Returned. So try this instead

Method1:

-(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];
}

Method2:

Once you set notification,the only way to edit it ,is canceling the old one and recreate another one,so you can do this way,searching your existing one and cancel it.

`for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications]) 
{
        if([[aNotif.userInfo objectForKey:@"id"] isEqualToString:nId])
 {
            [[UIApplication sharedApplication]cancelLocalNotification:aNotif];
        }
    }`