更改 UNTimeIntervalNotificationTrigger 的重复值
changing repeats value of UNTimeIntervalNotificationTrigger
我有一个本地通知,我每 60 秒重复一次:
var trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true);
如果满足特定条件,我想将 UNTimeIntervalNotificationTrigger
的 repeats
值从 true
更改为 false
,即:
if (condition) {
trigger!.repeats = true;
}
但是这似乎不起作用,因为我认为我无法在创建对象后更改 repeats
值。
有什么方法可以做我想做的事吗?
您可以删除本地通知
UIApplication.shared.cancelAllLocalNotifications()
如果您想再次 true
然后再次分配
trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
可能是这部作品
我有一个本地通知,我每 60 秒重复一次:
var trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true);
如果满足特定条件,我想将 UNTimeIntervalNotificationTrigger
的 repeats
值从 true
更改为 false
,即:
if (condition) {
trigger!.repeats = true;
}
但是这似乎不起作用,因为我认为我无法在创建对象后更改 repeats
值。
有什么方法可以做我想做的事吗?
您可以删除本地通知
UIApplication.shared.cancelAllLocalNotifications()
如果您想再次 true
然后再次分配
trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
可能是这部作品