In-App NATIV 11.x.x

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.

7e6cdb1-Screenshot_2016-02-11-17-18-06.png

Call Show InApp

Call MoEInAppHelper.getInstance().showInApp(context) in the onResume() of your Fragment or onStart() of your activity. Refer to the API documentation for more details.

Additionally, you can block in-app on a specific screen or handle the status bar visibility using the InAppConfig object and pass it to the SDK using the MoEngage.Builder object. Use the configureInApps() to pass on the configuration to the SDK.
Refer to the InAppConfig API reference for all possible options.

Kotlin Java
// Set of activity classes on which in-app should not be shown
val inAppOptOut = mutableSetOf<Class<*>>()
inAppOptOut.add(SplashActivity::class.java)

val moengage = MoEngage.Builder(application, "XXXXXXXX")
    .configureInApps(InAppConfig(true, inAppOptOut))
    .build()
MoEngage.initialise(moengage)

Implementing Nudges

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

5b6d918-Screenshot_20160210-223723.png

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

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

Using in an Activity

Get an instance of the nudge view in the onCreate() and initialize the nudge view in the onStart() of the Activity.

Using in a Fragment

Get an instance of the nudge view in the onCreateView() and initialize the nudge view in the onResume() of the fragment.

Use the below code to get the instance of the NudgeView and initialize it.

Kotlin Java
// get instance of the view
val nudge = findViewById(R.id.nudge)
// initialize
nudge.initialiseNudgeView(activity)

Contextual InApp

You can restrict the in-apps based on the user context in the application apart from restricting InApp campaigns on a specific activity.
The context is not the same context as Android Context.  The user context in the application flow.

Set Context

Kotlin Java
val contextList = arrayListOf<String>("C1", "C2", "C3", "C4")
MoEHelper.getInstance(requireContext()).appContext = contextList

Reset Context

Kotlin Java
MoEHelper.getInstance(requireContext()).resetAppContext()
info

Note

Contextual InApp is supported starting SDK version 10.0.00.

GIF In Apps

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

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

When using the SDK version below 10.0.00 use Fresco instead of Glide for using gifs. Ensure to add the animated-gif artifact as well.

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 show In-Apps call  use the following:

Kotlin Java
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

For more information, refer to the InAppMessageListener and MoEInAppCampaign.

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

The application needs to notify MoEngage SDK whenever the In-App messages are displayed, clicked on, or dismissed as the application controls these actions. The following methods are called to notify the SDK. The campaign object provided to the application in the callback for self-handled in-app should be passed as a parameter to the following APIs.

Kotlin Java
// 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)

For more information, refer to the API documentation.

In-Apps Callback

Lifecycle callback

For InApp lifecycle callbacks like shown, dismissed implement the InAppLifeCycleListener. Refer to the API Reference for more details.
Note: This Listener was introduced in SDK version 11.4.00 if you are using an older version use InAppMessageListener

Deprecated Lifecycle Callback

Deprecated since 11.4.00

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 documentation of InAppMessageListener and MoEInAppCampaign for more details.

 

Handling Configuration change

Starting SDK version 11.4.00 in-apps are supported in both portrait and landscape modes. SDK internally handles in-app display on orientation change when the activity restart is handled by the system.

In case your activity is handling the configuration change by itself, you have to notify the SDK by invoking MoEInAppHelper.onConfigurationChanged() API for SDK to redraw the in-app when the activity receives onConfigurationChanged() callback.

Kotlin Java
override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    MoEInAppHelper.getInstance().onConfigurationChanged()
}
 

Testing In-App

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

SDK version below 11.0.00

Starting SDK version 10.0.00 showing of InApp automatically on Activity launch is deprecated. Use showInApp() instead.

To ensure backward compatibility despite the deprecation the SDK still shows in-app automatically on Activity launch.

To use shownInApp() follow these steps.

Opt-out default In-App Display

Opt-out of the default behavior on lifecycle callbacks. To opt-out call optOutDefaultInAppDisplay() in the MoEngage Builder when initializing the SDK.

Kotlin Java
val moEngage = MoEngage.Builder(this, "XXXXXXXXXXX")
        .optOutDefaultInAppDisplay()
        .build()
MoEngage.initialise(moEngage)

Suppressing In-App

If you want to suppress the In-APP in a particular activity e.g., the Payment page or splash screen add the activity list in the initializer object as described:

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

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?