[英]UILocalNotification receiving notification with repeatInterval of NSYearCalendarUnit (move fire date to next fire date)
I set the repeatInterval of my notification to NSYearCalendarUnit. 我将通知的repeatInterval设置为NSYearCalendarUnit。 When I received the notification, I see this notification information that I log:
收到通知时,我会看到以下日志记录的通知信息:
fire date = Tuesday, 13 May, 2014... next fire date = Wednesday, 13 May, 2015
Then I cancel the notification thinking that it will move the fire date to May 13 2015 然后,我取消了通知,认为它将触发日期移至2015年5月13日
[application cancelLocalNotification:locationNotification];
but it didn't... It really cancels the notification. 但是没有...它确实取消了通知。
But when I didn't cancel the notification, the notification is retained however my fire date remains the same, I want it to move to 2015 and the next fire date to move to 2016 但是,当我没有取消通知时,该通知会保留,但是我的触发日期保持不变,我希望它移至2015年,下一个触发日期移至2016年
fire date = Tuesday, 13 May, 2014... next fire date = Wednesday, 13 May, 2015
You should update the fire date of the notification. 您应该更新通知的生效日期。
Try with this: 试试这个:
// Maybe in your code you don't need this, but I write it anyway
[application cancelLocalNotification:locationNotification];
// This will create a new date one year past the current notification fire date
NSDateComponents * components = [[NSDateComponents alloc] init];
components.year = 1;
NSDate * newDate = [[NSCalendar currentCalendar] dateByAddingComponents:components toDate:localNotification.fireDate options:kNilOptions];
// Now you can update the localNotification fire date
localNotification.fireDate = newDate;
// Schedule it. Again, maybe you don't need this in your code
[application scheduleLocalNotification:localNotification];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.