在UILocalNotification我们使用NSCalendarUnitMinute像重复.....但我在iOS 10 UserNotification doc中找不到...我怎样才能NSCalendarUnitMinute在iOS 10中使用类似的重复UserNotification?
这是代码,它将在晚上8:30安排本地通知,并在每一分钟后重复.
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];
Run Code Online (Sandbox Code Playgroud) 直到iOS 9我们写local notifications这样的
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];
Run Code Online (Sandbox Code Playgroud)
我们在本地通知中repeatInterval,现在在WWDC2016Apple宣布User Notification其中包含
UNCalendarNotificationTrigger.
UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:YES];
Run Code Online (Sandbox Code Playgroud)上面的代码会在每分钟后触发通知.但无法设定日期.
NSDateComponents* date = [[NSDateComponents alloc] init];
date.hour = 8;
date.minute = 30;
UNCalendarNotificationTrigger* triggerC = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:date repeats:YES];
Run Code Online (Sandbox Code Playgroud)
上面的代码可以设置,重复将在明天8:30触发,而不是在分钟后.
在iOS 10中User Notification我如何设置重复频率的日期时间就像我们可以设置的一样UILocalNotification?
我希望 …