Deleting and adding a notification with a matching identifier one after another seems to work fine for me if they are on the same thread, as required by the docs. If they are on different threads, the newly added notification is deleted by the delete call on the previous line. Is the first case guaranteed to work?
According to the docs, removePendingNotificationRequests “executes asynchronously, removing the pending notification requests on a secondary thread.” I understand what asynchronous vs synchronous is, but it appears to me that UNUserNotificationCenter is blocking until the delete is finished. Is it?
I guess I’m not totally sure of the term thread-safe in this context. Are those asynchronous calls on a secondary thread managed as long as the center object is used on one thread at a time? Or does it mean that if it is used in multiple threads that it can crash?
UNUserNotificationCenter
Thread-Safety Information
You may use the shared user notification center object from any thread of your app. However, you should use this object from only one thread at a time. Do not try to use it from multiple threads simultaneously. Always assign your delegate object to the shared user notification center's delegate property before using the object. It is a programmer error to assign a delegate after calling methods that might return information to that delegate.