قالب وردپرس درنا توس
Home / IOS Development / How can I know when UNUserNotificationCenter's removeAllPendingNotificationRequests () is complete?

How can I know when UNUserNotificationCenter's removeAllPendingNotificationRequests () is complete?



The iOS documents state that UNUserNotificationCenter & # 39; s `removeAllPendingNotificationRequests () is asynchronous.

What I want to do is this:

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

  2. Schedule a bunch of new notifications, some of them may or may not have the same ID -is like what was there before

But since the documentation says that the method runs asynchronously on another thread (and there is no complete callback parameter) I worry that sometimes, depending on the vagaries of threads and timing and what not, step 1 will still go while i make things in step 2, and so it will also kill some of the new notifications i give.

This kind of thing is a little difficult to test manually, since it depends on the time. So I'm curious that anyone knows if this is something I should be worried about or not …


Source link