Reputation: 541
I want to make the UILocalNotification
with the date user selected, but if user does not tap on the Notification bar to launch app, will continue to push the Local notification after 10s. That means the app will push the 2 Local notifications:
I tried this code but it's not work:
UILocalNotification *reminderNote = [[UILocalNotification alloc]init];
reminderNote.fireDate = _selectedDate;
reminderNote.repeatInterval = NSSecondCalendarUnit;
reminderNote.alertBody = @"some text";
reminderNote.alertAction = @"View";
reminderNote.soundName = @"sound.aif";
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
reminderNote.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
Thanks in advance.
Upvotes: 1
Views: 594
Reputation: 9391
There are a couple things wrong with this:
UILocalNotification
's that frequently. From the Apple documentation:Note that intervals of less than one minute are not supported.
NSCalendarUnit
intervals, like every hour, every day, or every month. See this post for more information.Upvotes: 2
Reputation: 13833
I think you need to create separate object for UILocalNotification
create 2 different UILocalNotification object and fire it at different time
like
-(void) fireAtDate:(NSDate *) date {
UILocalNotification *reminderNote = [[UILocalNotification alloc]init];
reminderNote.fireDate = _selectedDate;
reminderNote.repeatInterval = NSSecondCalendarUnit;
reminderNote.alertBody = @"some text";
reminderNote.alertAction = @"View";
reminderNote.soundName = @"sound.aif";
reminderNote.fireDate = date;
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
}
...
[self fireDate([NSDate dateWithTimeIntervalSinceNow:0])];
[self fireDate([NSDate dateWithTimeIntervalSinceNow:10])];
Upvotes: 0