Push Token Callback
MoEngage plugin triggers thepushTokenGenerated event whenever device token is generated. This event is a common trigger for both iOS and Android platforms and is available from plugin version 6.0.0. Refer to the below code to set listener to the same:
MoEPushToken instance with the following definition:
Push Click Callback
MoEngage plugin triggers thepushClicked event whenever a notification is clicked. This event is a common trigger for both iOS and Android platforms and is available from plugin version 6.0.0. Refer to the below code to set the listener to the same:
App.js.
NotificationPayload received in the callback is a MoEPushPayload instance with the following definition:
clickedAction Map
platform- Native platform from which callback is triggered. Possible values -android,iosisDefaultAction- This key is present only for the Android Platform. It’s a boolean value indicating if the user clicked on the default content or not. true if the user clicks on the default content else false.clickedAction- Action to be performed on notification click.clickedAction.type- Type of click action. Possible valuesnavigationandcustomAction. Currently,customActionis supported only on Android.clickAction.payload- Action payload for the clicked action.clickedAction.payload.type- Type of navigation action defined. Possible valuesscreenName,deepLink,richLanding. Currently, in the case of iOS, richlanding and deep-link URL are processed internally by the SDK and not passed in this callback therefore possible value in case of iOS is onlyscreenName.clickAction.value- value entered for navigation action or custom payload.clickAction.kvPair- Custom key-value pair entered on the MoEngage Platform.payload- Complete campaign payload.
Android Payload
If the user clicks on the default content of the notification the key-value pair and campaign payload can be found inside thepayload key. If the user clicks on the action button or a push template action the action payload would be found inside clickedAction.You can use the
isDefaultAction key to check whether the user clicked on the default content or not and then parse the payload accordingly.
iOS Payload
In the case of iOS, you would always receive the key-value pairs with respect to clicked action inclickedAction the property. Refer to this Notification Payload to know the iOS notification payload structure.