繁体   English   中英

如何从本地通知中获取下一个开火日期?

[英]How do I get next fire date from a local notification..?

我正在使用UILocalNotifications实现提醒应用程序,并希望允许用户设置重复模式。 对于重复模式,请使用NSDayCalenderUnitNSWeekCalendarUnit等。

我在LocalNotification类中没有看到任何属性可以从通知中获取下一个触发日期。

“ {发射日期= 2013年9月6日星期五,印度标准时间,时区=亚洲/加尔各答(GMT + 05:30)偏移19800,重复间隔= NSWeekCalendarUnit,重复计数= UILocalNotificationInfiniteRepeatCount,下一次火灾日期= 2013年9月6日,星期五,印度标准时间上午7:05:00,用户信息= {\\ n
kRemindMeNotificationDataKey = \\“测试通知\\”; \\ n}}“

任何人都可以帮助我,从本地通知中获取下一个开火日期。

提前致谢。

您可以使用UILocalNotification两个属性:

  1. 消防日期
  2. repeatInterval

基于这两个属性创建一个NSDate。

NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval fromDate:self.localNotification.fireDate];

NSDate *nextFireDate = [calendar dateFromComponents:comps];

试试这个代码

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM