【发布时间】:2017-11-06 11:03:33
【问题描述】:
以前我在我的应用程序中使用UILocalNotification 进行提醒。
但如上所述 API 在 iOS 10.0 中已弃用,现在需要使用 UserNotifications Framework 的UNNotificationRequest。
使用UILocalNotification 我可以设置触发日期和重复间隔,如下所示:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSDate *tomorrow = [NSDate dateWithTimeInterval:(24*60*60) sinceDate:[NSDate date]];
localNotification.fireDate = tomorrow;
if(repeatUnit!=0){
localNotification.repeatInterval = NSWeekCalendarUnit;
}
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
在上面的代码中,我可以设置明天的通知将触发的日期,并且我设置了 1 周的重复间隔,这将从触发日期开始。
如何使用 UserNotifications Framework 的 UNNotificationRequest 来实现这一点。
因为在新的 api 中我们可以使用触发器UNCalendarNotificationTrigger 和UNTimeintervalNotificationTrigger 来启动UNNotificationRequest。
有什么方法可以像UILocalNotification 那样设置吗?
【问题讨论】:
标签: ios objective-c iphone xcode uilocalnotification