Requests authorization to interact with the user when local and remote notifications are delivered to the user's device.
- iOS 10.0+
- macOS 10.14+
- Mac Catalyst 13.0+Beta
- tvOS 10.0+
- watchOS 3.0+
The authorization options your app is requesting. You may combine the available constants to request authorization for multiple items. Request only the authorization options that you plan to use. For a list of possible values, see
The block to execute asynchronously with the results. This block may be executed on a background thread. The block has no return value and has the following parameters:
A Boolean value indicating whether authorization was granted. The value of this parameter is
truewhen authorization was granted for one or more options. The value is
falsewhen authorization is denied for all options.
An object containing error information or
nilif no error occurred.
If your app's local or remote notifications involve user interactions, you must request authorization for the system to perfom those interactions on your app's behalf. Interactions include displaying an alert, playing a sound, or badging the app's icon.
The first time your app ever calls the method, the system prompts the user to authorize the requested interactions. The user may grant or deny authorization, and the system stores the user’s response so that subsequent calls to this method do not prompt the user again. After determining the authorization status, the user notification center object executes the block in the
completion parameter. Use that block to make any adjustments to your app's behavior. For example, if authorization was denied, you might notify a remote notification server not to send notifications to the user’s device.
The user may change the allowed interactions at any time in system settings. Use the
get method to determine what interactions are currently allowed for your app.