MoEngage Docs

SDK Installation

Install MoEngage's React Native plugin using the npm package manager. And then link your native dependencies :

$ npm install react-native-moengage
$ react-native link

After installing the plugin lets move on to platform specific configuration.

Android

Download

In android/settings.gradle add the following

include ':react-native-moengage'
project(':react-native-moengage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-moengage/android')

In android/app/build.gradle add the following

dependencies {
    ...
      
    implementation project(':react-native-moengage')
    implementation "com.moengage:moe-android-sdk:+
}

Add the MoEngage React Package in the Application class's getPackages() Also enable auto integration in the onCreate()

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(), new MoEReactPackage());
    }
  };

  @Override public void onCreate() {
    super.onCreate();
    // 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);
  }

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

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

import com.moengage.react.MoEReactPackage;
import com.moengage.core.MoEngage;

iOS

Install the native MoEngage iOS SDK(version 4.0.0 OR above) by using CocoaPods. Here create the Podfile in the ios directory of your project.

NOTE :

Incase if you get errors in the test targets of the project, go to build settings of the test target and add -lc++ flag to Other Linker Flags as shown below :

Update Header Search Path

Select the MoEReactBridge target in MoEReactBridge.xcodeproj and go to Header Search Paths section in Build Settings as shown below. Here update the search path $(SRCROOT)/../../../../ios to include your Project's main directory which contains the AppDelegate file as shown below.

NOTE:

Updating the Header Search Path is important as the MoEngage React Native plugin needs access to the AppDelegate file of your project.

Thats it!! SDK is successfully installed in the project, and ready to use.


SDK Installation


Suggested Edits are limited on API Reference Pages

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