У меня есть этот кусок кода, который я использую для стрельбы местного уведомления каждый день в середине ночи:UILocalNotification - Огонь и повторить в определенное время каждый день
//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);
}
Однако мне нужно другое местное уведомление стрелять каждый день в 13:00. Как это достигается? Я не понимаю, как приведенный выше код может быть адаптирован для достижения этой цели ..
Спасибо большое,
Джек
посмотреть мой ответ, там namaztimes - это мой массив, у которого есть время стрельбы в нем, в этом коде мне нужно стрелять по локальной нотификации 5 раз в день (например, каждый день), так что, согласно его настройке, вы можете настроить его – Charan