Установить repeatInterval в локальном уведомлении
Я хочу установить интервал повтора на значение, которое пользователь выбирает из палитры дат. У меня в приложении есть палитра даты в режиме обратного отсчета типа. Если пользователь выбирает 4 пика 15 минут из палитры дат, тогда я устанавливаю скорость срабатывания, используя следующий код и звонит сигнал тревоги. ,
[NSDate dateWithTimeIntervalSinceNow:[pickerTimer countDownDuration]]
Но я хочу, чтобы уведомление повторялось каждые 4 часа 15 минут, пока пользователь не отменит его. Я провел много исследований, но не могу понять. Код, который я использовал до сих пор:
localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:[pickerTimer countDownDuration]]];
if(localNotification.fireDate){
[self _showAlert:@"Time is scheduled" withTitle:@"Daily Achiever"];
}
localNotification.timeZone = [NSTimeZone systemTimeZone];
localNotification.alertBody=@"alaram";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[localNotification setAlertAction:@"View"];
[localNotification setRepeatInterval:[pickerTimer countDownDuration]];
//The button's text that launches the application and is shown in the alert
// [localNotification setAlertBody:[alertBodyField text]]; //Set the message in the notification from the textField's text
//[localNotification setHasAction: YES]; //Set that pushing the button will launch the application
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]]; //Set the Application Icon Badge Number of the application's icon to the current Application Icon Badge Number plus 1
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval=NSHourCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; //Schedule the notification with the system
//[alertNotification setHidden:NO]; //Set the alertNotification to be shown showing the user that the application has registered the local notification
Пожалуйста, помогите мне решить. Заранее большое спасибо.