<分区>
直到iOS 9
我们这样写本地通知
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = pickerDate;
localNotification.alertBody = self.textField.text;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.repeatInterval = NSCalendarUnitMinute;
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
在本地通知中,我们有repeatInterval
,现在在WWDC2016
Apple 宣布User Notification
,其中包含
- UNTimeIntervalNotificationTrigger。
UNCalendarNotificationTrigger。
UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:YES];
上面的代码将在每分钟后触发通知。但无法设置日期。
NSDateComponents* date = [[NSDateComponents alloc] init];
date.hour = 8;
date.minute = 30;
UNCalendarNotificationTrigger* triggerC = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:date repeats:YES];
日期上面的代码可以设置并且重复将在明天 8:30 触发,而不是在分钟之后。
在 iOS 10 User Notification
中,我如何设置重复频率的日期时间,就像我们在 UILocalNotification
中设置的那样?
我想在明天晚上 8 点 30 分安排用户通知
,并在每分钟后继续重复,就像我在顶部指定的关于本地通知