MoEngage Docs

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]"

Variables :

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

Sample Implementation

Refer to this Sample Implementation here on Github

SDK Initialization(Android Only)

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

Create Application class and its instance

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

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

Make sure your app has appcompat-v7 version 26 or above.

If you are facing issues with imports please add the below imports

import com.moengage.core.Logger;
import com.moengage.core.MoEngage; 

iOS Integration

MoEngage Framework in Embedded Binaries

Ensure that the MoEngage.framework is present in Embedded Binaries(General > Embedded Binaries). If not present then add the same.

Add script to remove Unwanted Architectures

Do this if not already done: Select App Target and go to Build Phase and add a Run Script step to your build steps, set it to use /bin/sh and enter the following script:

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
    FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
    echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

    EXTRACTED_ARCHS=()

    for ARCH in $ARCHS
    do
        echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
        lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
        EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
    done

    echo "Merging extracted architectures: ${ARCHS}"
    lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
    rm "${EXTRACTED_ARCHS[@]}"

    echo "Replacing original executable with thinned version"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

This script is for removing unsupported architectures while exporting the build OR submitting app to the app store.

For Plugin version 3.2.0 and below:

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