MoEngage Docs

In-App NATIV

In-App NATIV Campaigns target your users by showing a message while the user is using your app. They are very effective in providing contextual information and help to cross-sell/up-sell on desired screens of your app or/and on desired actions performed by the user in your app.

Implementing InApp Messaging

By default In-Apps are shown on Activity Lifecycle Callbacks and no additional integration is required for using In-Apps.

Granular Control for In-Apps

🚧

This feature is available from SDK version 9.4.01 and above.

In-App notifications are triggered only on Activity Lifecycle Callbacks, hence if your application has a Single Activity and multiple fragments In-App message will only be shown on application launch which might not always be an ideal behaviour and you want to trigger in-app at a later point of time in the application's lifecycle.
To have such control you can call MoEInAppHelper.getInstance().showInApp(context) in the onResume() of your Fragment or onStart() of your activity. Refer to the API documentation for more details.

Before you can use this method to control in-app display you need to opt-out of the default behaviour on lifecycle callbacks. To opt-out call optOutDefaultInAppDisplay() in the MoEngage Builder when initialising the SDK. Refer to the documentation for more details on this API.

Note: In-Apps can only be triggered via Activity lifecycle callbacks or MoEInAppHelper.getInstance().showInApp(context) both cannot be used simultaneously.

Testing In-App

Refer to this link to read more about how to create and test in-apps.

Suppressing In-App

If you want to suppress the In-APP in a particular activity for e.g., the Payment page or splash screen add the activity list in the initialiser object as shown below

ArrayList<Class> inAppOptOut = new ArrayList<>();
    inAppOptOut.add(MainActivity.class);
    MoEngage moEngage =
        new MoEngage.Builder(this, "XXXXXXXXXX")
            .optOutInAppOnActivity(inAppOptOut)
            .build();
    MoEngage.initialise(moEngage);

This would suppress from any inapp message from showing up in that activity.

Implementing Nudges

Nudges are non disruptive messages which can be placed anywhere in the activity.

Add the following code in the activity/fragment layout file.

<com.moengage.widgets.NudgeView
    android:id="@+id/nudge"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</com.moengage.widgets.NudgeView>

Using Nudge inside an Activity

In your activity's, onCreate() add the following lines of code.

NudgeView nv = (NudgeView)findViewById(R.id.nudge);

Add the below in the onStart() of your activity

nv.initialiseNudgeView(activity); //pass the activity context

Using Nudge inside a Fragment

If you are using nudges in Fragments then get an instance of the nudge view in the onCreateView() as follows

NudgeView nv = (NudgeView)findViewById(R.id.nudge);

Initialise the nudge view in the onResume() of the fragment

nv.initialiseNudgeView(getActivity());

GIF inApps

In-App messages support GIFs with Glide
To use GIFs you need to add below dependency in your build.gradle file.

implementation "com.github.bumptech.glide:glide:4.9.0"
annotationProcessor "com.github.bumptech.glide:compiler:4.9.0"

Self Handled InApps

Self handled In Apps are messages which are delivered by the SDK but showing it has to be done by the App.
To shown In-Apps call the below method.

MoEInAppHelper.getInstance().getSelfHandledInApp(context)
MoEInAppHelper.getInstance().getSelfHandledInApp(context);

This method should be called in the onResume() of your Fragment or onStart() of your activity.
The above method is asynchronous and does not return the payload immediately.
To get the payload implement the InAppMessageListener and override the onSelfHandledAvailable(). Once the payload is available this method will be called with the payload.
The payload can be accessed using MoEInAppCampaign.selfHandledCampaign
Refer to the InAppMessageListener documentation and MoEInAppCampaign documentation for more details.

To get the above callback you would need to register the listener with the SDK using MoEInAppHelper.getInstance().registerListener()

Tracking Statistics for Self Handled In-Apps

Since display, click and dismiss for Self-Handled InApp shown controlled by the application we need you to notify the SDK whenever the In-App is Shown, Clicked, Dismissed. Below are the methods you need to call to notify the SDK. The campaign object provided to the application in the callback for self-handled in-app should be passed in as a parameter to the below APIs.

// call whenever in-app is shown
MoEInAppHelper.getInstance().selfHandledShown(context, inAppCampaign)
// call whenever in-app is clicked
MoEInAppHelper.getInstance().selfHandledClicked(context, inAppCampaign)
 // call whenever in-app is dismissed
MoEInAppHelper.getInstance().selfHandledDismissed(context, inAppCampaign)
// call whenever in-app is shown
MoEInAppHelper.getInstance().selfHandledShown(context, inAppCampaign);
// call whenever in-app is clicked
MoEInAppHelper.getInstance().selfHandledClicked(context, inAppCampaign);
 // call whenever in-app is dismissed
MoEInAppHelper.getInstance().selfHandledDismissed(context, inAppCampaign);

Refer to the API documentation for more details.

In-Apps Callback

SDK provides callbacks to the client application whenever is shown or closed/dismissed.
To get a callback implement the InAppMessageListener and override the onShown() and onClosed() respectively.
To get the above callback you would need to register the listener with the SDK using MoEInAppHelper.getInstance().registerListener()

Refer to the InAppMessageListener documentation and MoEInAppCampaign documentation for more details.

Updated 2 months ago


In-App NATIV


Suggested Edits are limited on API Reference Pages

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