Push Notifications

Configuring Push Notifications in Android

To use Push Notification in your Cordova application you need to configure Firebase into your application, refer to the Push Notification documentation to configure Push Notification in your application.

In case, your application is handling the push token registration and push payload we highly recommend you use the native Android methods(mentioned in the documentation above) for passing the token and the payload to the SDK.
If for whatever reason you wish to pass the push token and payload to the SDK using the Cordova component/Javascript code use the below APIs

Passing Push Token

var moe = MoECordova.init(YOUR_APP_ID);

Passing Push Payload

var moe = MoECordova.init(YOUR_APP_ID);
  Passing payload and token from JavaScript is only supported for Firebase Messaging Service.

We highly recommend you to use the Android native APIs for passing the push payload to the MoEngage SDK instead of the Cordova/JavaScript APIs. Cordova Engine might not get initialized if the application is in the killed state which will lead to poor push reachability or delivery.

Customizing Push notification

If required the application can customize the behavior of notification by using Native Android code (Java/Kotlin). To learn more about the customization refer to Advanced Push Configuration documentation.
Instead of extending PushMessageListener as mentioned in the above document extend PluginPushCallback.

Refer to the below documentation for Push Amp+, Push Templates, and Geofence.

Push Amp Plus

Push Templates

GeoFence Push

Configuring Push Notifications in iOS

APNS Certificate 

To send push notifications in iOS, create an APNS certificate and upload it to the dashboard. Complete the following steps:

Adding Push Entitlement to your Project

Once the APNS Certificate is uploaded, enable Push Entitlement in the Xcode project. For that select your app target, then go to Capabilities. Here enable the Push Notifications capability for your app as shown below :


Uninstall Tracking

We make use of silent pushes to track uninstalls. For tracking uninstalls of all the users, enable Remote Notification background mode in-app capabilities for the same as shown below :


Push Registration

After this you will have to register for push notification by using registerForPushNotification method of the plugin as shown below :

var moe = MoECordova.init(YOUR_APP_ID);

Push token generated is received from `onPushTokenGenerated` callback

moe.on('onPushTokenGenerated', function (payloadInfo) {
    console.log('pushToken generated' + JSON.stringify(payloadInfo)); 

Rich Push and Templates Support:

Please refer to the Native iOS SDK docs for supporting Rich Push(images/videos/audio in the notification) and Templates in the app:

Callback in JavaScript on Notification Click

To get a callback in javascript on notification click you need to register for a click listener as shown below.

Minimum Plugin version required : 3.0.0

var moe = MoECordova.init(YOUR_APP_ID);
moe.on('onPushClick', function(payloadInfo) {
    //add logic here


NotificationPayload received in the callback onPushClick will have the following structure:

  "accountMeta": {
    "appId": ""
  "data": {
    "platform": "android/iOS",
    "isDefaultAction": false,
    "clickedAction": {
      "type": "navigation/customAction",
      "payload": {
        "type": "screenName/deepLink/richLanding",
        "value": "",
        "kvPair": {
          "key1": "value1",
          "key2": "value2"
    "payload": {}

accountMeta.appId - The appID of MoEngage.
data.platform - Native platform from which callback is triggered. Possible values - androidios
data.isDefaultAction - 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.
data.clickedAction - Action to be performed on notification click.
data.clickedAction.type - Type of click action. Possible values navigation and customAction. Currently, customAction is supported only on Android.
data.clickAction.payload - Action payload for the clicked action.
data.clickedAction.payload.type - Type of navigation action defined. Possible values screenNamedeepLinkrichLanding. 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 only screenName.
data.clickAction.payload.value - value entered for navigation action or custom payload.
data.clickAction.payload.kvPair - Custom key-value pair entered on the MoEngage Platform.
data.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 the payload 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 in clickedAction key. Refer to this link for knowing the iOS notification payload structure.

Was this article helpful?
0 out of 0 found this helpful