带有重复间隔设置的 UILocalNotification NSWeekdayCalendarUnit 不会每周触发 [英] UILocalNotification with repeatInterval set NSWeekdayCalendarUnit doesn't trigger weekly
问题描述
我正在尝试将本地通知设置为每周重复一次.
这是我的设置:
I'm trying to setup local notification to repeat weekly.
Here's my setup:
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
...
localNotification.repeatInterval = NSWeekdayCalendarUnit;
在控制台日志中:
localNotif:{开火日期 = 2015 年 4 月 24 日星期五下午 12:27:33 新加坡标准时间,时区 = 亚洲/新加坡 (GMT+8) 偏移 28800,重复间隔 = NSWeekdayCalendarUnit,重复计数 = UILocalNotificationInfiniteRepeatCount,下一个开火日期 = 2015 年 4 月 25 日星期六下午 12:27:33 新加坡标准时间,用户信息 = {KUserLocalNotficationKey = "2015-04-24 04:27:33 +0000";}}
localNotif: {fire date = Friday, April 24, 2015 at 12:27:33 PM Singapore Standard Time, time zone = Asia/Singapore (GMT+8) offset 28800, repeat interval = NSWeekdayCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Saturday, April 25, 2015 at 12:27:33 PM Singapore Standard Time, user info = { KUserLocalNotficationKey = "2015-04-24 04:27:33 +0000"; }}
如您所见,下一个触发日期是在第二天触发.这是一个错误吗?
我已经在 iOS 7.1、8.1、8.3 上测试过了.
As you can see, the next fire date is trigger on the next day. Is this a bug?
I've tested it in iOS 7.1, 8.1, 8.3.
推荐答案
PLz 试试这个
UILocalNotification *localNotif=[[UILocalNotification alloc]init];
localNotif.fireDate =currentDate;
localNotif.timeZone=[NSTimeZone defaultTimeZone];
localNotif.alertBody = @"MazeRoll";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
localNotif.repeatInterval=NSWeekCalendarUnit;
UIApplication *app=[UIApplication sharedApplication];
[app scheduleLocalNotification:localNotif];
NSLog(@"sdfsdfsdf%@",[[UIApplication sharedApplication] scheduledLocalNotifications]);
这篇关于带有重复间隔设置的 UILocalNotification NSWeekdayCalendarUnit 不会每周触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!