Reputation: 726
I am trying to set repeat reminder... I am using this code:
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[[[task.reminder objectAtIndex:i] valueForKey:@"AlertTime"] doubleValue]];
localNotif.fireDate = date;
localNotif.timeZone = [NSTimeZone systemTimeZone];
localNotif.alertBody = [self textForAlertWithTask:task withIndex:i];
localNotif.alertAction = @"Review";
localNotif.soundName = [[defaults valueForKey:REMINDER_SOUND] stringByAppendingString:@".caf"];
localNotif.applicationIconBadgeNumber = 0;
if([task isRepeat] && [task.type isEqualToString:TYPE_TASK]){
NSDate *fireDate = [Repeat getNextRepeatedReminder:task];
if (!fireDate) return;
localNotif.fireDate = fireDate;
int interval = [[task.recurrence valueForKey:RECURRENCE_UNIT] integerValue];
if(interval == REPEAT_UNIT_DAY){
// DebugLog(@"Task is repeat - daily");
localNotif.repeatInterval = NSDayCalendarUnit;
}
else if(interval == REPEAT_UNIT_WEEK){
// DebugLog(@"Task is repeat - weekly");
localNotif.repeatInterval = NSWeekCalendarUnit;
}
else if(interval == REPEAT_UNIT_MONTH){
localNotif.repeatInterval = NSMonthCalendarUnit;
}
else if(interval == REPEAT_UNIT_YEAR){
localNotif.repeatInterval = NSYearCalendarUnit;
}
else {
// DebugLog(@"error in setting a repeating alarm!");
}
// DebugLog(@"Repeat - settings reminder to be - %d",interval);
}
DebugLog(@"scheduling the notification with title:%@\n%@",localNotif.alertBody, localNotif);
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
The log is:
{fire date = Monday, December 9, 2013, 7:20:50 PM Israel Standard Time, time zone = Asia/Jerusalem (GMT+02:00) offset 7200, repeat interval = NSDayCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Monday, December 9, 2013, 7:20:50 PM Israel Standard Time, user info = (null)}
As you can see the fire date and the next fire date is the same, how can it be ... ? the repeat interval is: "NSDayCalendarUnit" ...
Upvotes: 0
Views: 1254
Reputation: 313
Your firedate
has too much information to work.
For example:
If your localNotif.repeatInterval = NSDayCalendarUnit;
firedate
only contain Hours minutes seconds.
Upvotes: 0
Reputation: 539745
Your notification hasn't fired yet, therefore the next fire date is the initial fire date.
Upvotes: 3