[英]How do I get next fire date from a local notification..?
I am implementing a reminder application using UILocalNotifications
, and want to allow user to set repeat mode. 我正在使用
UILocalNotifications
实现提醒应用程序,并希望允许用户设置重复模式。 For repeating mode used NSDayCalenderUnit
, NSWeekCalendarUnit
, etc.. 对于重复模式,请使用
NSDayCalenderUnit
, NSWeekCalendarUnit
等。
I didn't see any property in LocalNotification
class to get the next fire date from a notification. 我在
LocalNotification
类中没有看到任何属性可以从通知中获取下一个触发日期。
Example 例
"{fire date = Friday, September 6, 2013, 7:05:00 AM India Standard Time, time zone = Asia/Kolkata (GMT+05:30) offset 19800, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Friday, September 6, 2013, 7:05:00 AM India Standard Time, user info = {\\n
“ {发射日期= 2013年9月6日星期五,印度标准时间,时区=亚洲/加尔各答(GMT + 05:30)偏移19800,重复间隔= NSWeekCalendarUnit,重复计数= UILocalNotificationInfiniteRepeatCount,下一次火灾日期= 2013年9月6日,星期五,印度标准时间上午7:05:00,用户信息= {\\ n
kRemindMeNotificationDataKey = \\"Test Notification\\";\\n}}"kRemindMeNotificationDataKey = \\“测试通知\\”; \\ n}}“
Any one please help me out to get the next fire date from a local notification. 任何人都可以帮助我,从本地通知中获取下一个开火日期。
Thanks in advance. 提前致谢。
You have two properties from UILocalNotification
which you can use: 您可以使用
UILocalNotification
两个属性:
Create a NSDate based on these two properties. 基于这两个属性创建一个NSDate。
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval fromDate:self.localNotification.fireDate];
NSDate *nextFireDate = [calendar dateFromComponents:comps];
try this code 试试这个代码
NSCalendar *calendar = notification.repeatCalendar;
components.week = 1;
if (!calendar) {
calendar = [NSCalendar currentCalendar];
}
NSDate *nextFireDate = [calendar dateByAddingComponents:components toDate:notification.fireDate options:0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.