Migrating to 4.x.x

This migration is required only for people who have integrated plugin version 3.2.0 or below. If you plugin version is greater 3.2.0 you can ignore this step.

Removing existing plugin

Remove MoEngage SDK Plugin

cordova plugin remove moengagesdk

Remove MoEngage Push Extension, if added. Use the command cordova plugin list to check whether the plugin is installed or not.

cordova plugin remove moengagepushextension

Install the new plugin

Install the new MoEngage SDK plugin.

cordova plugin add moengagesdk --variable APP_ID="[your_app_id]"

Variables :

  • APP_ID = App id found under the settings page on the MoEngage dashboard.

Initialise SDK(only for Android)

To initialise SDK create a class extending Application class of Android and override onCreate().
Inside the onCreate() initialise the SDK as shown below.

// this is the instance of the application class and "XXXXXXXXXXX" is the APP ID from the dashboard.
MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXXX")
            .build();
    MoEngage.initialise(moEngage);

Make sure your application class is defined in the AndroidManifest.xml file as well.

Setting up Push Notification(only Android)

MoEngage SDK supports both FCM and GCM, based on what you are using in your application install the appropriate plugin.
The SDK no longer ships with Google's GCM or FCM library please ensure you have added the appropriate dependency in your app.

FCM:

cordova plugin add cordova-moengage-fcm-dependency

GCM:

cordova plugin add cordova-moengage-gcm-dependency

If MoEngage SDK is registering for push notification add the appropriate FCM/GCM listeners.

FCM

cordova plugin add cordova-moengage-fcm-listeners

GCM

cordova plugin add cordova-moengage-gcm-listeners

Adding Push Related Meta Data

Refer to Push Notification documentation and add all the required meta-data for push notifications to work.