1

I already schedule a daily notification with this code:

NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:7];
[components setMonth:3];
[components setYear:2014];
[components setHour:9];
NSInteger minute = arc4random() % 59;
[components setMinute:minute];
[components setSecond:0];
[calendar setTimeZone:[NSTimeZone defaultTimeZone]];
NSDate *dateToFire = [calendar dateFromComponents:components];

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.userInfo = @{@"uid": DailyNotificationUid};
localNotification.fireDate= dateToFire;
localNotification.timeZone = [NSTimeZone defaultTimeZone];

NSString *body = NSLocalizedString(@"Local Notification Alert Body", nil);
localNotification.alertBody = body;
localNotification.alertAction = NSLocalizedString(@"Local Notification Alert Action", nil);
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval = NSCalendarUnitDay;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

But I miss a expire date. The notification should end on christmas without that the user has to start the app. Is this possible?

zeiteisen
  • 7,078
  • 5
  • 50
  • 68
  • Possibly duplicate question you can cheek this post [http://stackoverflow.com/questions/6340664/delete-a-particular-local-notification][1] [1]: http://stackoverflow.com/questions/6340664/delete-a-particular-local-notification –  Aug 27 '14 at 11:35
  • how you do that ???? – 9to5ios Dec 21 '14 at 08:32

1 Answers1

1

You can't specify expiry date in UILocalNotification. Instead you will need to create UILocalNotification till christmas. But there is also a limit of 64 UILocalNotification.

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100