0

link1 link2

If I want to set local notification to repeat every 2 week than how to achieve this?

I have read several questions and answers here, they have mention to reschedule local notification but how to reschedule local notification while application is in background ?

I will appreciate any help on same.

Thanks.

Community
  • 1
  • 1
S S
  • 646
  • 1
  • 7
  • 16
  • check this it may help you http://www.techotopia.com/index.php/Scheduling_iOS_7_Local_Notifications – Mohit Aug 07 '14 at 06:02

1 Answers1

0

To reschedule UILocal Notification use this ,

NSDateFormatter *dat= [[NSDateFormatter alloc]init];
[dat setLocale:[NSLocale currentLocale]];
[dat setTimeZone:[NSTimeZone systemTimeZone]];

//[dat setDateFormat:@"YYYY-MM-dd"];// YYYY-MM-dd hh:mm a
//NSString *dateM=[dat stringFromDate:datM];
//[dat setDateFormat:@"YYYY-MM-dd h:mm a"];
NSDate *reminderDate=[NSDate date];
//Use manual option too for timing    
reminderDate =[reminderDate dateByAddingTimeInterval:1*24*60*60*7];


UILocalNotification  *localnoification = [[UILocalNotification alloc]init];
localnoification.fireDate=reminderDate;
localnoification.timeZone = [NSTimeZone defaultTimeZone];
localnoification.alertBody = word;
localnoification.alertAction = @"Tap to see word of the day";
//May Add Custom Sound Also
//localnoification.soundName = UILocalNotificationDefaultSoundName;

localnoification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;

//localnoification.applicationIconBadgeNumber = 1;
localnoification.repeatInterval = NSDayCalendarUnit;

[[UIApplication sharedApplication] scheduleLocalNotification:localnoification];