iOS 10-每个"x"重复通知分钟 [英] iOS 10 - Repeating notifications every "x" minutes

查看:60
本文介绍了iOS 10-每个"x"重复通知分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 10中,如何设置从特定日期/时间开始在几分钟内重复的本地通知.

In iOS 10, how can I set local notifications to repeat in minutes starting from a particular date/time.

例如,从9月8日上午11点开始每15分钟触发一次本地通知吗?假设下面的dateTimeReminder.date的时间为09/08 11 AM.

For example, trigger local notification every 15 minutes starting from 11 AM on 8th September? Assume that, below, dateTimeReminder.date has 09/08 11 AM.

let dateStart = self.dateTimeNotif.date
let notifTrigger = UNCalendarNotificationTrigger.init(dateMatching: NSCalendar.current.dateComponents([.day, .month, .year, .hour, .minute], from: dateStart), repeats: true)
let notificationRequest = UNNotificationRequest(identifier: "MYNOTIF", content: notifContent, trigger: notifTrigger)

UNUserNotificationCenter.current().add(notificationRequest, withCompletionHandler: nil)

使用上面的代码,我可以将时间安排在每小时的特定时间,每天的特定时间等.但是,如何将其转换为每"x"分钟"?感谢您的帮助.

With the above code, I have a possibility to schedule at a particular minute of every hour, at a particular hour of each day and so on. But how do I turn it into "every "x" minutes"? Any help is appreciated.

相似的问题-推荐答案

搜索了很多之后,我得出的结论是,Swift 3目前不支持此功能.对于正在寻找此功能的每个人,我建议暂时使用UILocalNotification(尽管在iOS 10中已弃用),但是一旦它支持此功能,便应稍后迁移到UNUserNotification.以下是一些其他问题和资源,它们帮助我得出了这一结论.另外,请遵循该主题中的所有答案和评论,以更深入地了解它所讨论的特定场景.

After searching around quite a bit, I've come to the conclusion that Swift 3, at this point, doesn't support this feature. For everyone looking for this functionality, I'd suggest using UILocalNotification for now (although deprecated in iOS 10), but later migrate to UNUserNotification once it supports this feature. Here are some additional questions and resources that have helped me to reach this conclusion. Also, please follow all the answers and comments in this thread to get more insight into which particular scenario it talks about.

  • 使用不推荐使用的API通常是个坏主意.通常,请尽快迁移到新的API.不建议将上述解决方案作为永久解决方案.

每两周发送一次本地通知

http://useyourloaf.com/blog/local-notifications-with-ios-10/

https://github.com/lionheart/openradar-mirror/issues/14941

这篇关于iOS 10-每个"x"重复通知分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆