Instance Method


Requests authorization to interact with the user when local and remote notifications are delivered to the user’s device.


func requestAuthorization(options: UNAuthorizationOptions = [], completionHandler: @escaping (Bool, Error?) -> Void)



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 UNAuthorizationOptions.


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 true when authorization was granted for one or more options. The value is false when authorization is denied for all options.


An object containing error information or nil if no error occurred.


If your app’s local or remote notifications involve user interactions, you must request authorization for the system to perform 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 completionHandler 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 getNotificationSettings(completionHandler:) method to determine what interactions are currently allowed for your app.

See Also

Managing Settings and Authorization

var supportsContentExtensions: Bool

A Boolean value indicating whether the current device supports notification content extensions.

struct UNAuthorizationOptions

Constants for requesting authorization to interact with the user.