【问题标题】:How to set Local Notification repeat interval on Prayer time everyday different times?如何在每天不同时间的祈祷时间设置本地通知重复间隔?
【发布时间】:2017-01-13 17:30:46
【问题描述】:

在本地通知中有 repeatInterval 属性,我们可以将单位重复间隔设置为分钟、小时、天、周、年等。

我希望在祈祷时间和每天相同的过程中重复间隔。

所以每个祈祷时间都会收到本地通知。

祷告时间是每天不同的时间

我该怎么做?

【问题讨论】:

  • 我建议为一天中的每个祈祷小时创建一个本地通知,重复间隔为 1 天。
  • @Larme,据我所知,祈祷时间每天都在变化,因为至少有一些是基于日落/日出之类的。
  • @jcaron 你是对的
  • @Larme 祈祷时间每天都会变化

标签: ios objective-c uilocalnotification


【解决方案1】:

试试这个:

NSCalendar *calen = [NSCalendar autoupdatingCurrentCalendar] ;
NSDateComponents *components = [calen components:(NSCalendarUnitYear | NSCalendarUnitMonth |  NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:[NSDate date]];
[components setHour:9];
[components setMinute:30];
[components setSecond:00];

UILocalNotification *notif = [[UILocalNotification alloc]init];
notif.fireDate = [calen dateFromComponents:components];
notif.repeatInterval = NSCalendarUnitDay;
[notif setAlertBody:@"Its prayer time..."];
[[UIApplication sharedApplication] scheduleLocalNotification:notif];

希望它对你有用。

【讨论】:

  • 但是每天时间都不一样,每天都安排好时间
  • 是的,我已经有了祈祷时间的计算方法。也可以得到时间
  • 每天都有不同的时间?
  • 也许你应该使用两个本地通知来实现这一点。每天一个通知,在处理方法中收到每日通知后,您可以获得当天的祈祷时间,并为这些特定时间间隔注册另一个通知。
  • @iOSGeek 我也提出了同样的建议
猜你喜欢
  • 2017-10-16
  • 1970-01-01
  • 2011-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多