Called when your app has received a remote notification.
- iOS 3.0–10.0Deprecated
- tvOS 9.0–10.0Deprecated
The app object that received the remote notification.
A dictionary that contains information related to the remote notification, potentially including a badge number for the app icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iOS converts to an
NSDictionaryobject; the dictionary might contain only property-list objects plus
application(_: method instead of this one whenever possible. If your delegate implements both methods, the app object calls the
If the app is running, the app calls this method to process incoming remote notifications. The
user dictionary contains the
aps key whose value is another dictionary with the remaining notification data. Although you should not need the information in the
aps dictionary, you can retrieve its contents using the following keys:
alert—The value is either a string for the alert message or a dictionary with two keys:
show-view. The value of the
bodykey is a string containing the alert message and the value of the
show-viewkey is a Boolean. If the value of the
false, the alert’s View button is not shown. The default is to show the View button which, if the user taps it, launches the app.
badge—A number indicating the quantity of data items to download from the provider. This number is to be displayed on the app icon. The absence of a
badgeproperty indicates that any number currently badging the icon should be removed.
sound—The name of a sound file in the app bundle to play as an alert sound. If “default” is specified, the default sound should be played.
user dictionary may also have custom data defined by the provider according to the JSON schema. The properties for custom data should be specified at the same level as the
aps dictionary. However, custom-defined properties should not be used for mass data transport because there is a strict size limit per notification (256 bytes) and delivery is not guaranteed.
If the app is not running when a remote notification arrives, the method launches the app and provides the appropriate information in the launch options dictionary. The app does not call this method to handle that remote notification. Instead, your implementation of the
application(_: method needs to get the remote notification payload data and respond appropriately.
For more information about how to implement remote notifications in your app, see Local and Remote Notification Programming Guide.