1

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?

2 Answers2

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
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