MoEngage Docs

SDK Initialization

Android

Get APP ID from the Settings Page on the MoEngage dashboard and initialize the MoEngage SDK in the Application class's onCreate()

Note: It is recommended that you initialize the SDK on the main thread inside onCreate() and not create a worker thread and initialize the SDK on that thread.

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

In case you are facing issues with the import add the below import statement in your java file.

import com.moe.pushlibrary.MoEHelper;
import com.moengage.core.MoEngage;
import com.moengage.react.MoEInitializer;

Refer to the API reference doc for a detailed list of possible configurations.

iOS

For initializing the project, you will have to provide the AppID of your MoEngage App.

📘

Getting App ID :

Login to your MoEngage account, go to Settings in the left panel of the dashboard. Under App Settings, you will find your APP ID.

  • Go to info.plist of your project.
  • Create MoEngage dictionary
  • Inside MoEngage dictionary, Add MoEngage_APP_ID key and provide AppID.

🚧

IMPORTANT [Introduced in plugin version 6.0.0]

Make sure to call the below intializeSDKWithLaunchOptions: method which has been introduced from plugin version 6.0.0.

Once the AppID changes are done, go to your AppDelegate file and call the below initialization method in application:didFinishLaunchingWithOptions: method:

📘

Data Redirection:

Make sure to call redirectDataToRegion: method with relevant MOE_REGION as an argument as shown below, eg: if your account is present in the EU Data Center, use MOE_REGION_EU. For more info refer the following link.

#import <ReactNativeMoEngage/MOReactInitializer.h>
 
@implementation AppDelegate
  
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // Redirect Data Method
  [MoEngage redirectDataToRegion:MOE_REGION_DEFAULT]; //MOE_REGION_SERV3, MOE_REGION_EU, MOE_REGION_DEFAULT
  
  [[MOReactInitializer sharedInstance] intializeSDKWithLaunchOptions:launchOptions];
  
  // Rest of the implementation
  return YES;
}

Initialise React-Native Component

Initialize the MoEngage Plugin in the App.js of your application by calling the ReactMoE.initialize() in the render() or componentDidMount()

import ReactMoE from 'react-native-moengage'

ReactMoE.initialize();

🚧

NOTE:

Make sure you are setting the Push/InApp callback listeners before calling theinitialize().

Install/Update differentiation

Since you might integrate us when your app is already on the App Store, we would need to know whether your app update would be an actual UPDATE or an INSTALL.

Have logic in place to differentiate Install and Update and make use of the setAppStatus() method to track the same as shown below:

const ReactMoE = require('react-native-moengage')
 
//For Fresh Install of App
ReactMoE.setAppStatus(MoEAppStatus.Install);

 // For Existing user who has updated the app
ReactMoE.setAppStatus(MoEAppStatus.Update);

Updated 14 days ago


What's Next

Identify User

SDK Initialization


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.