Tom*_*ing 12 ios usernotifications
说今天是星期一,下午1点.我想从今天下午2点开始,从我的iOS应用程序安排每周本地通知.我这样做:
NSDateComponents *components = [[[NSDateComponents alloc]init]autorelease];
components.weekday = 2;
components.hour = 14;
components.minute = 0;
UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:YES];
//then make a UNMutableNotificationContent and UNNotificationRequest and schedule it
Run Code Online (Sandbox Code Playgroud)
但如果我想在下周一下午2点开始,我该如何跳过第一次?
要以另一种方式提出问题,如何UNCalendarNotificationTrigger在某个任意时间安排重复开始,而不是第一次出现重复间隔?
这里要跳出框框思考。
您可以将服务器配置为在未来某个时间(即明天清晨)向您的手机发送静默推送通知。当您在后台收到推送通知时,您可以使用它来设置本地日历通知。通过这种方式,您可以有效地跳过第一个通知,或安排它们在未来的任何时间开始。
当然,您不应该完全依赖 APNS 网络,因此您需要在应用程序处于前台时通过 API 调用来跟踪通知的状态。
| 归档时间: |
|
| 查看次数: |
866 次 |
| 最近记录: |