Before diving into requesting notification permissions from your users, it is important to understand how Apple and web platforms handle permissions.
Notifications cannot be shown to users if the user has not "granted" your application permission. The overall notification permission of a single application can be either be "not determined", "granted" or "declined". Upon installing a new application, the default status is "not determined".
In order to receive a "granted" status, you must request permission from your user (see below). The user can either accept or decline your request to grant permissions. If granted, notifications will be displayed based on the permission settings which were requested.
If the user declines the request, you cannot re-request permission, trying to request permission again will immediately return a "denied" status without any user interaction - instead the user must manually enable notification permissions from the device Settings UI (or via a custom UI).
On Apple based platforms, once a permission request has been handled by the user (authorized or denied), it is not possible to re-request permission. The user must instead update permission via the device Settings UI:
- If the user denied permission altogether, they must enable app permission fully.
- If the user accepted requested permission (without sound), they must specifically enable the sound option themselves.
Although overall notification permission can be granted, the permissions can be further broken down into 'settings'.
Settings are used by the device to control notifications behavior, for example alerting the user with sound. When requesting permission, you can provide arguments if you wish to override the defaults. This is demonstrated in the above example.
The full list of permission settings can be seen in the table below along with their default values:
|Sets whether notifications can be displayed to the user on the device.|
|If enabled, Siri will read the notification content out when devices are connected to AirPods.|
|Sets whether a notification dot will appear next to the app icon on the device when there are unread notifications.|
|Sets whether notifications will appear when the device is connected to CarPlay.|
|Sets whether provisional permissions are granted. See Provisional authorization for more information.|
|Sets whether a sound will be played when a notification is displayed on the device.|
The settings provided will be stored by the device and will be visible in the iOS Settings UI for your application.
You can also read the current permissions without attempting to request them via the
Devices on iOS 12+ can use provisional authorization. This type of permission system allows for notification permission to be instantly granted without displaying a dialog to your user. The permission allows notifications to be displayed quietly (only visible within the device notification center).
To enable provision permission, set the
provisional argument to
true when requesting permission:
When a notification is displayed on the device, the user will be presented with several actions prompting to keep receiving notifications quietly, enable full notification permission or turn them off: