Tuesday 30 July 2019

How can I know when UNUserNotificationCenter's removeAllPendingNotificationRequests() has completed?

The iOS docs say that UNUserNotificationCenter's `removeAllPendingNotificationRequests() is asynchronous.

What I want to do is this:

  1. Call removeAllPendingNotificationRequests() to get rid of all my scheduled notifications

  2. Schedule a bunch of new notifications, some of which may or may not have the same IDs as what was there previously

But since the documentation says that the method is asynchronously running on another thread (and there is no completion callback parameter) I'm worried that sometimes, depending on the vagaries of threads and timing and whatnot, that step #1 will still be going as I am creating things in step 2 and therefore it will also kill some of the new notifications I'm making.

This kind of stuff is a little tricky to test manually, since it depends on timing. So I'm curious is anyone knows if this is something I should be worried about or not...



from How can I know when UNUserNotificationCenter's removeAllPendingNotificationRequests() has completed?

No comments:

Post a Comment