我正在设置重复提醒...我正在使用此代码:
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];
日志是:
{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)}
你可以看到火灾日期和下一个火灾日期相同,它怎么可能......?重复间隔为:“NSDayCalendarUnit”......
答案 0 :(得分:3)
您的通知尚未解除,因此下一个开火日期 是初始开火日期。
答案 1 :(得分:0)
您的firedate
有太多信息无法使用。
例如:
如果您的localNotif.repeatInterval = NSDayCalendarUnit;
firedate
仅包含小时分秒。