firedate
sets the time during which the notification is triggered for the first time, and repeatInterval
is the interval between repetitions of the notification. Thus, the code in the question provides a notification of 30 minutes (60 * 30 seconds), and then repeats every hour.
Unfortunately, you can only schedule notifications for repeating at exact intervals determined by NSCalendar constants : for example, every minute, every hour, every day, every month, but not in a multiple of these intervals.
Fortunately, to receive a notification every 30 minutes, you can simply schedule two notifications: one right now, after 30 minutes, and repeat every hour every time. For instance:
UILocalNotification *reminderNote = [[UILocalNotification alloc]init]; reminderNote.fireDate = [NSDate dateWithTimeIntervalSinceNow:60 * 30]; reminderNote.repeatInterval = NSHourCalendarUnit; reminderNote.alertBody = @"some text"; reminderNote.alertAction = @"View"; reminderNote.soundName = @"sound.aif"; [[UIApplication sharedApplication] scheduleLocalNotification:reminderNote]; reminderNote.fireDate = [NSDate dateWithTimeIntervalSinceNow:60 * 60]; [[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
source share