I’m trying here to repeat a local notification for every hour. so I tried this sample code:
UILocalNotification *reminderNote = [[UILocalNotification alloc]init];
reminderNote.fireDate = [NSDate dateWithTimeIntervalSinceNow:60 * 60];
reminderNote.repeatInterval = NSDayCalendarUnit;
reminderNote.alertBody = @"some text";
reminderNote.alertAction = @"View";
reminderNote.soundName = @"sound.aif";
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
and it worked fine. But when I try to repeat it at a specific minute of the hour, say every hour sharp, or every hour and 6 mins. I just couldn’t figure out a way to do that! I tried to change SinceNow to anything else but it’s not working!
Is there a way change it? or any other sample code that I should work on?
Thanks in Advance.
If the repeat interval between the first and the second reminder repetition is different from the interval for the rest, you need to define a new local notification with the correct fire date, e.g. 6 minutes after the hour. Then set the repeat interval to the
NSHourCalendarUnit.You can specify the interval with the usual pattern with
NSCalendarandNSDateComponents. This is well documented here.