【问题标题】:how can I use repeatinterval every 10 minutes ??如何每 10 分钟使用一次重复间隔?
【发布时间】:2011-08-11 10:53:16
【问题描述】:
有没有办法设置本地通知repeatinterval每10分钟一次。
我尝试使用
localnotification.repeatInterval = NSMinuteCalendarUnit*3;
和
localNotif.repeatInterval = 640;
它不起作用。
所以请你指导我。 :)
【问题讨论】:
标签:
iphone
objective-c
ios
uilocalnotification
【解决方案1】:
正如 Mundi 所说,repeatInterval 必须是 NSCalendarUnit,并且只能包含:NSWeekCalendarUnit、NSMonthCalendarUnit、NSDayCalendarUnit、NSHourCalendarUnit、..
所以每 10 分钟收到一次通知。使用 6 个每小时重复一次的通知,并在通知之间设置 10 分钟。
【解决方案3】:
NSTimeInterval 以秒为单位,因此十分钟将是 600.0,而不是 640。
NSMinutesCalenderUnit 具有任意定义的值,并且不包含每分钟的秒数。
您是否检查过您是否使用scheduleLocalNotification: 正确安排了通知,并且您是否在您的 AppDelegate 中实施了application:didReceiveLocalNotification:?
【解决方案4】:
您是否也必须取消通知?像这样
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];