HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In


Only customers onboarded prior to July 15, 2022 have access to the ODP Campaigns and have the ability to configure push notifications. For more information, contact your Customer Success Manager.

To use push notifications as part of an ODP campaign, your phone apps must be set up to receive them. For instructions on installing the ODP React Native module in your app, see [Install & Initalize](🔗).

## Multiple sources

ODP does not have to be your only source of push notifications. If you set them up, any other source may still operate correctly with your application. For example, if you use the same `p12` keys when setting up a service to send iOS notifications. However, you should ensure that you can handle payloads of various shapes from various services without causing problems.

## Permissions

By default, the call to `Zaius.configure()` prompts the user for push notification access. While this is often acceptable, sometimes you do not want to prompt the user as the first thing the app does. To change this, pass `requestPermissions: false` as an option to `Zaius.configure()`.


You **must** call `Zaius.requestPermissions()` at some point in the future or you will not be able to receive push notifications.

Similarly, the `onRegister` callback will not be called until `Zaius.requestPermissions()` is called.

## Callbacks

The ODP SDK allows for some custom behavior at certain critical parts of the app's and notification's lifecycle.

### onNotification

The `onNotification` callback is called when a push notification gets to the phone. By default, the `onNotification` option sent to `Zaius.configure()` does nothing. You can override this by sending a function:

Due to how the underlying module handles push notification payloads, the shape of the JSON payload that is available as `notification` is unfortunately not very strict and is different between iOS and Android.

  • On iOS, the notification is not displayed to the user if the app is open. It is shown only if the app is in the background.

  • On Android, the notification is shown regardless of app status.


This callback is always called, even if the notification is not interacted with. The `notification` argument reliably contains a field called `userInteraction` which is `true` if the user has tapped on the notification and `false` otherwise. When in the foreground on iOS, the app still receives a callback on this function, and the `userInteraction` field is `false`.


When the user interacts with the notification, the SDK [automatically queues an event](🔗) that lets ODP know the interaction took place.

### onRegister

The `onRegister` callback is called when push notifications are fully enabled on the phone's side. That is, the callback is called with a push token that can identify the unique phone. Having this token does not necessarily mean the server can send a notification, but the phone can receive one.


When this callback is invoked, the SDK also [automatically queues an event](🔗) to tell ODP about this push token so it knows where to send pushes.