gpt4 book ai didi

ios - 为什么 UILocalNotifications 不重复?

转载 作者:行者123 更新时间:2023-11-29 01:15:49 25 4
gpt4 key购买 nike

我想运行 UILocalNotifications 并每 2 分钟重复一次。为此,我这样做:

let reminderNote: UILocalNotification = UILocalNotification()
reminderNote.fireDate = NSDate(timeIntervalSinceNow: 60 * 2)
reminderNote.repeatInterval = NSCalendarUnit.Hour
reminderNote.alertBody = "some text"
reminderNote.alertAction = "View"

UIApplication.sharedApplication().scheduleLocalNotification(reminderNote)

它只运行一次,之后就不再运行了。

我认为是因为这条线:

reminderNote.repeatInterval = NSCalendarUnit.Hour

如何每 1.5 或 2 小时重复一次通知?

最佳答案

直接你不能。

很遗憾repeatInterval只能设置为TimeUnit比如Hour,Minute,Second

例如:假设您想要每 2 分钟重复一次通知,您将需要创建 30 个每小时重复一次的通知。

关于ios - 为什么 UILocalNotifications 不重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35196777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com