
直到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公布了包含的用户通知
> 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用户通知中,我如何设置重复频率的日期时间,就像我们可以在UIlocalnotification中设置一样?
我希望明天晚上8:30安排用户通知,并在每分钟后继续重复,就像我在顶部指定的关于本地通知的代码一样
@H_403_22@解决方法 对于iOS 10,您可以这样使用:NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond fromDate:fireDate];UNCalendarNotificationTrigger* trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:YES];
它与iOS 9代码具有相同的效果.要重复,您只需使用要重复的组件即可.
@H_403_22@ @H_403_22@ 总结以上是内存溢出为你收集整理的ios – 如何在用户通知中设置重复频率全部内容,希望文章能够帮你解决ios – 如何在用户通知中设置重复频率所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)