Shi Zhang
Shi Zhang

Reputation: 163

changing repeats value of UNTimeIntervalNotificationTrigger

i have a local notification that i am repeating every 60s:

var trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true);

i want to change the repeats value of the UNTimeIntervalNotificationTrigger from true to false if a certain condition is met i.e.:

if (condition) {
    trigger!.repeats = true;
}

however this doesn't seem to work as i dont think i can change the repeats value after creating the object.

is there any way to do what i'm trying to do?

Upvotes: 0

Views: 849

Answers (1)

Sachin Kishore
Sachin Kishore

Reputation: 324

You can remove the local notification as

UIApplication.shared.cancelAllLocalNotifications()

And if you want to true again then again assign

trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)

May be this Work

Upvotes: 1

Related Questions