如何在 Swift 中多次显示通知?
How to show Notification in Swift more than once?
有没有每隔 15 秒显示 swift 的通知?我通过
检查过
notification.fireDate=NSDate(timeIntervalSinceNow: 15)
但不是每次只显示一次都有效,我们如何循环执行?
您可以设置 localNotification.repeatInterval
属性 类型为 NSCalendarUnit
您不能每 15 秒安排一次通知。通知之间的最短时间间隔为 1 分钟,这也不太可能需要。
var repeatInterval: NSCalendarUnit { get set }
Description The calendar interval at which to reschedule the
notification. If you assign a calendar unit such as weekly
(NSWeekCalendarUnit) or yearly (NSYearCalendarUnit), the system
reschedules the notification for delivery at the specified interval.
Note that intervals of less than one minute are not supported. The
default value is 0, which means that the system fires the notification
once and then discards it.
所以只需按如下设置即可:
notification.repeatInterval = .Minute
有没有每隔 15 秒显示 swift 的通知?我通过
检查过notification.fireDate=NSDate(timeIntervalSinceNow: 15)
但不是每次只显示一次都有效,我们如何循环执行?
您可以设置 localNotification.repeatInterval
属性 类型为 NSCalendarUnit
您不能每 15 秒安排一次通知。通知之间的最短时间间隔为 1 分钟,这也不太可能需要。
var repeatInterval: NSCalendarUnit { get set }
Description The calendar interval at which to reschedule the notification. If you assign a calendar unit such as weekly (NSWeekCalendarUnit) or yearly (NSYearCalendarUnit), the system reschedules the notification for delivery at the specified interval. Note that intervals of less than one minute are not supported. The default value is 0, which means that the system fires the notification once and then discards it.
所以只需按如下设置即可:
notification.repeatInterval = .Minute