I have this piece of code which I use for firing a local notification each day at mid night:
//Get todays midnight
NSDate *alertTime = [NSDate date];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSUInteger preservedComponents = (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit);
alertTime = [calendar dateFromComponents:[calendar components:preservedComponents fromDate:alertTime]];
UIApplication *app = [UIApplication sharedApplication];
//Set up the local notification
UILocalNotification *notification = [[UILocalNotification alloc] init];
if(notification){
//Set fire date to alert time
notification.fireDate = alertTime;
//Set time zone to default
notification.timeZone = [NSTimeZone defaultTimeZone];
//Repeat the notification everyday (fires at same time
//as initial notification)
notification.repeatInterval = NSDayCalendarUnit;
// schedule notification
[app scheduleLocalNotification:notification];
NSLog(@"%@", notification.fireDate);
}
However I need another local notification to fire each day at 13:00. How is this accomplished? I don't understand how the above code can be adapted to achieve this..
Thanks a lot,
Jack
If you have the time which you have to fire notification every day, you should do this
then from here it will connect to the main notification firing method
[self scheduleNotificationForDate:myNewDate];