gpt4 book ai didi

ios - scheduleLocalNotification 下一个开火日期不起作用

转载 作者:行者123 更新时间:2023-11-28 20:10:32 25 4
gpt4 key购买 nike

我正在尝试设置重复提醒...我正在使用此代码:

    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” ...

最佳答案

您的通知尚未触发,因此下一个触发日期是初始触发日期。

关于ios - scheduleLocalNotification 下一个开火日期不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20466322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com