The Sample Moe Developer Hub

Welcome to the Sample Moe developer hub. You'll find comprehensive guides and documentation to help you start working with Sample Moe as quickly as possible, as well as support if you get stuck. Let's jump right in!

SDK Integration

To get up and running with MoEngage on Cordova, there a couple of steps to get you there.

Adding MoEngage Plugin

Add moengagesdk plugin to cordova project as shown below :

cordova plugin add moengagesdk --variable APP_ID="[your_app_id]" --variable SENDER_ID="[your_sender_id]" --variable NOTIFICATION_ICON="[notification_small_icon_drawable]" --variable NOTIFICATION_TYPE="[single/multlipe]" --variable NOTIFICATION_LARGE_ICON="[notification_small_icon]" --variable SKIP_GCM_REGISTRATION="[whether_moengage should_register for push]"

Variables :

  • APP_ID = App id found under the settings page on the MoEngage dashboard.
  • SENDER_ID = The project number as mentioned on GOOGLE CLOUD CONSOLE PROJECTS PAGE, prefix "id:" to the project number
  • NOTIFICATION_ICON = The notification small icon which will be used to set to notifications posted
  • NOTIFICATION_TYPE = The notification type which will be used, SINGLE OR MULTIPLE. Default behaviour is single, use @integer/notification_type_multiple for multiple
  • NOTIFICATION_LARGE_ICON = The notification large icon which will be used to set to notifications posted.
  • SKIP_GCM_REGISTRATION = false, If you want MoEngage to register for Push Notification, else true.

Adding Lifecycle Callbacks for Android

Add activity lifecycle callbacks.
Where to find your CordovaActivity?
platforms—>android—>src—>[packagename]—>[ActivityName]

public class BaseActivity extends Activity {
  private MoEHelper mHelper;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHelper = MoEHelper.getInstance(this)
  }

  @Override
  protected void onStart() {
    super.onStart();
    mHelper.onStart(this);
  }

  @Override
  protected void onStop() {
    super.onStop();
    mHelper.onStop(this);
  }

  @Override
  protected void onResume() {
    super.onResume();
    mHelper.onResume(this);
  }

  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mHelper.onSaveInstanceState(outState);
  }

  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mHelper.onRestoreInstanceState(savedInstanceState);
  }
}  

iOS Integration

Set -ObjC linker flag :

Open your project in Xcode, select your project. Go to Build Settings -> Linker -> Other Linker Flags and add -ObjC flag.

Only for moengagesdk plugin version 2.0.1 and earlier

Make changes in your appdelegate class as mentioned in the following link


SDK Integration

To get up and running with MoEngage on Cordova, there a couple of steps to get you there.