-
Notifications
You must be signed in to change notification settings - Fork 5
push setup
For implementing our mobile push channel, please ensure that the Basic Setup steps have been completed to add the SDK to your app. Once completed, follow the instructions below to finish the required setup for mobile push for iOS.
In order to generate a P8 key for Apple services first access your account at https://developer.apple.com/ and select 'Certificates, Identifiers & Profiles', then select 'Keys' on the left.

Select 'Create a Key' and on the form 'Register a New Key' enter a meaningful name such as 'APNS Access Key' and check the 'Enable' checkbox for 'Apple Push Notifications service (APNs)', click 'Continue'.

On the confirmation screen double check the APNs enablement is set then click 'Register'
On the final screen take note of your KeyID and download the key. Note that you can only download the key once, if lost the key must be revoked and re-created.
Downloading the key will save a .p8 file with the access credentials.
You now have all the details to configure your Mobile push channel. Access your Optimove dashboard and select 'Settings' then under the 'OptiMobile' section, select 'Mobile Push Config' and click the cog next to the Apple icon. Select APNs P8 and select your file, enter your other details and click 'Configure'.
In your app project settings use the "+ capability" button to add the Background Modes and Push Notifications capabilities, in Background Modes you should have the "Remote Notifications" mode checked.
Note you must use a real device to test push notifications on iOS because simulators cannot register for push notifications.
When you consider it appropriate, you need to request permission from the user to send them push notifications. You can potentially use an in-app message to prompt the user to accept push at a later time.
Whilst you can handle this yourself, Optimove provides a convenience method:
Optimove.shared.pushRequestDeviceToken()This will prompt the user to accept push notifications with the badge, alert, and sound settings. When the user accepts, the Optimove SDK will store the push token.
If at a later stage the user wishes to opt out from push notifications without blocking them via the Notification Center Optimove provides a convenience method:
Optimove.shared.pushUnregister()This will mark the token as soft-deleted in Optimove to allow for easy re-enabling later.