I want to be able to pause a recurring notification for one time and the time it needs to be trigged, I want it to trigger. I know about removeAllPendingNotifications
. But not sure that will do the trick as it seems to remove it completely. What are your thoughts?
Asked
Active
Viewed 767 times
1
2 Answers
1
You can use getPendingNotificationRequests
and select the identifiers you need to cancel then pass them to removePendingNotificationRequests(withIdentifiers: [String])
UNUserNotificationCenter.current().getPendingNotificationRequests { (reqs) in
var ids = [String]()
reqs.forEach {
if $0.identifier == "someId" {
ids.append($0.identifier)
}
}
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers:ids)
}
`

Shehata Gamal
- 98,760
- 8
- 65
- 87
-
Wouldn't this remove the repeating notification completely? Or does this actually pauses it? Not too sure. – Apr 28 '19 at 13:00
-
1there is no pause either remove or leave – Shehata Gamal Apr 28 '19 at 13:07
1
My solution is to remove the notification for the day using the code above or just know the identifier and remove the pending notification identifier. Then add the notification back but for the next day.
i.e An example is like a to do app that has recurring task but do not want to be notified of a task that is completed.
This stackoverflow as the code: Scheduling local notifications to repeat daily from tomorrow in Swift