Asks the delegate how to handle a notification that arrived while the app was running in the foreground.
- iOS 10.0+
- macOS 10.14+
- UIKit for Mac 13.0+Beta
- tvOS 10.0+
- watchOS 3.0+
The shared user notification center object that received the notification.
The notification that is about to be delivered. Use the information in this object to determine an appropriate course of action. For example, you might use the information to update your app’s interface.
The block to execute with the presentation option for the notification. Always execute this block at some point during your implementation of this method. Use the
optionsparameter to specify how you want the system to alert the user, if at all. This block has no return value and takes the following parameter:
If your app is in the foreground when a notification arrives, the shared user notification center calls this method to deliver the notification directly to your app. If you implement this method, you can take whatever actions are necessary to process the notification and update your app. When you finish, call the
completion block and specify how you want the system to alert the user, if at all.
If your delegate does not implement this method, the system behaves as if you had passed the
UNNotification option to the
completion block. If you do not provide a delegate at all for the
UNUser object, the system uses the notification’s original options to alert the user.