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

时间:2013-09-05 12:40:13

标签: ios uilocalnotification

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

我没有在LocalNotification课程中看到任何属性来通知通知。

示例

  

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

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

提前致谢。

2 个答案:

答案 0 :(得分:0)

您可以使用UILocalNotification中的两个属性:

  1. fireDate
  2. repeatInterval
  3. 根据这两个属性创建NSDate。

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

答案 1 :(得分:0)

试试这段代码

NSCalendar *calendar = notification.repeatCalendar;
components.week = 1;
         if (!calendar) {
             calendar = [NSCalendar currentCalendar];
         }            
NSDate *nextFireDate = [calendar dateByAddingComponents:components toDate:notification.fireDate options:0];
相关问题