Swift每24小时发送一次本地通知

时间:2014-11-29 18:03:22

标签: ios swift uilocalnotification

我正在寻找一种方法,可以在某个时间每24小时触发一次本地通知。

例如: 我有一个约会选择器。 我将日期选择器时间设置为3.02pm。 下一次下午3点2分发出本地通知。 一遍又一遍地重复这个。

我已成功在日期选择器选择的时间成功拨打本地通知,但我该如何每24小时重复一次?

3 个答案:

答案 0 :(得分:1)

在iOS 10中不推荐使用

UILocalNotification。请改用UNNotificationRequest

myNotificationRequest.trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60*60*24, repeats: false)

答案 1 :(得分:0)

您可以使用 repeatInterval 属性重复本地通知。 要每天重复本地通知,请将此行添加到您的代码中

myLocalNotification.repeatInterval = NSCalendarUnit.CalendarUnitDay

答案 2 :(得分:0)

在Swift 3中

myLocalNotification.repeatInterval = NSCalendar.Unit.day
相关问题