iOS Push Notifications
1. Set notifications token
Overrideapplication(_:didRegisterForRemoteNotificationsWithDeviceToken:) to handle notifications token.Call the
setNotificationsToken() method to enable Qonversion to send the push notifications.
2. Handle notifications
Override theuserNotificationCenter(_ center: UNUserNotificationCenter, didReceive response) method to handle received notifications. Call handleNotification() with the notification data. The method returns true when a push notification is received from Qonversion, and Qonversion SDK will try to handle it. If you have not set up the in-app screen with Qonversion, you need to handle a notification yourself.For push notifications from other services, the method returns false, so you also need to handle a notification yourself.
Android Push Notifications
1. Set notifications token
To enable Qonversion push notifications, callsetNotificationsToken() and pass a device registration token. Here you can find more information about the ways to retrieve the token.You have to call the
setNotificationsToken method for every newly generated token.
2. Handle notifications
To define what happens when users click on push notifications, you have to specify an instance of thePendingIntent object and pass the RemoteMessage as extra data. Then call the setContentIntent() method of the NotificationCompat.Builder.
🚧 Applications that target Android 12 or higher can’t start activities from services or broadcast receivers that are used as notification trampolines. Make sure you use Activity as an automation push handler for notification intent.In the NotificationActivity
onCreate() method, retrieve an instance of the RemoteMessage and call handleNotification() with the message data. The method returns true when a push notification is received from Qonversion and Qonversion SDK will try to handle it. If you have not set up the in-app screen with Qonversion, you need to handle a notification yourself.For push notifications from other services, the method returns false, so you also need to handle a notification yourself.
Cross-platform Push Notifications
1. Set notifications token
Call thesetNotificationsToken() method to enable Qonversion push notifications. Pass APNs token for iOS devices or Firebase Cloud Messaging token for Android devices.****
Flutter
React Native
Unity
2. Handle notifications
CallhandleNotification() with the notification data to define what happens when users click on push notifications. The method returns true when a push notification is received from Qonversion and Qonversion SDK will try to handle it. If you have not set up the in-app screen with Qonversion, you need to handle a notification yourself.For push notifications from other services, the method returns false, so you also need to handle a notification yourself.
📘 Notification data
The handleNotification method accepts an object instance of Map. Retrieving this object depends on your implementation of push notifications.
Flutter
React Native
Unity
Custom payload
You can add a custom payload to the notification while creating it in the Qonversion dashboard. The data should be a valid JSON object. Neither JSON arrays nor simple values like strings or integers are allowed. It is done to simplify the method’s return value type. Then you can get parsed payload on your client side using the following method of the corresponding SDK providing the received push notification data.Flutter
React Native
Unity