Push notifications are sent to a device via the Apple Push Notification Service (APNS) using a device token that is unique to each app and user. These tokens can change over time, so Apple recommends requesting the latest device token each time the app opens. This device token is then sent to Swrve and used when sending push notifications to this particular user’s device.
The first time a push-enabled app requests such a device token, the device displays a prompt to the user requesting permission for your app to send push notifications to the user of the device. The following is an example from an airline app:
If the user selects Don’t Allow, then Swrve is not given a device token and cannot send push notifications cannot to that user. This is why the timing of such a permission request is crucial—generally, it is bad practice to ask the user immediately after install because they have no experience of your app yet and so may select this option by default.
Swrve has built-in functionality in the SDK to delay the timing if this first device token request to a time when you believe the user is most likely to agree to such messaging. For more information, see the iOS integration guide.
If the user selects Allow, then Swrve is passed a device token. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.
If you are testing the timing of this permission request, you may want to repeatedly simulate such a first-time run of your app. You can leave the app uninstalled for a day. Alternatively, you can achieve the same effect without waiting by following these steps:
Step 1: Delete your app from the device.
Step 2: Turn the device off completely and turn it back on.
Step 3: Navigate to Settings > General > Date & Time and set the date ahead a day or more.
Step 4: Turn the device off completely again and turn it back on.
Step 5: Re-install your app and open it.
If your app is configured to request push permission at the start of a session, a dialog box is displayed which requests permission to send push notifications. If your app is configured to delay push permission until a certain event, then navigate your app until this event is triggered. The permission dialog box is then displayed.