InApp 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.
Call the showInApp()
wherever InApp has to be shown in the app as shown below :
import { MoECapacitorCore } from 'capacitor-moengage-core';
MoECapacitorCore.showInApp();
Self-Handled InApps
Self-handled In Apps are messages which are delivered by the SDK but displaying it has to be handled by the App.
To get self-handled In-App call the below method.
import { MoECapacitorCore } from 'capacitor-moengage-core';
MoECapacitorCore.getSelfHandledInApp();
The payload for self-handled in-app is returned via a callback. Register a callback as shown below.
import { MoECapacitorCore, MoEInAppSelfHandledCampaignData } from 'capacitor-moengage-core';
MoECapacitorCore.addListener("inAppCampaignSelfHandled", (data: MoEInAppSelfHandledCampaignData) => {
console.log(" Received callback 'inAppCampaignSelfHandled', data: " + JSON.stringify(data))
});
Tracking Statistics
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.
import { MoECapacitorCore, MoEInAppSelfHandledCampaignData } from 'capacitor-moengage-core';
//Track self handled shown
MoECapacitorCore.selfHandledShown(selfHandledCampaignData)
//Track self handled primary widget cliked
MoECapacitorCore.selfHandledPrimaryClicked(selfHandledCampaignData)
//Track self handled widget clicked
MoECapacitorCore.selfHandledClicked(selfHandledCampaignData)
//Track self handled dismissed
MoECapacitorCore.selfHandledDismissed(selfHandledCampaignData)
InApp Callbacks
warning |
Warning Make sure you are calling |
We provide callbacks whenever an InApp campaign is shown, dismissed, or clicked you can register for the same as shown below.
import { MoECapacitorCore, MoEInAppLifecycleData, MoEInAppNavigationData, MoEInAppCustomActionData } from 'capacitor-moengage-core';
MoECapacitorCore.addListener("inAppCampaignShown", (data: MoEInAppLifecycleData) => {
console.log(" Received callback 'inAppCampaignShown', data: " + JSON.stringify(data))
});
MoECapacitorCore.addListener("inAppCampaignDismissed", (data: MoEInAppLifecycleData) => {
console.log(" Received callback 'inAppCampaignDismissed', data: " + JSON.stringify(data))
});
MoECapacitorCore.addListener("inAppCampaignClicked", (data: MoEInAppNavigationData) => {
console.log(" Received callback 'inAppCampaignClicked', data: " + JSON.stringify(data))
});
MoECapacitorCore.addListener("inAppCampaignCustomAction", (data: MoEInAppCustomActionData) => {
console.log(" Received callback 'inAppCampaignCustomAction', data: " + JSON.stringify(data))
});
Event Type | Event Name |
---|---|
InApp Shown | inAppCampaignShown |
InApp Clicked | inAppCampaignClicked |
InApp Dismissed | inAppCampaignDismissed |
InApp Clicked with Custom Action | inAppCampaignCustomAction |
Handling Orientation Change
info |
Note This is only for the Android platform |
MoEngage SDK has to be notified when the device orientation changes for SDK to handle in-app display.
There are two ways to do it:
- Add the API call in the Android native part of your app
- Call MoEngage plugin's
onOrientationChanged()
Add the API call in the Android native part of your app
Notify the SDK when onConfigurationChanged()
API callback is received in your App's Activity class.
import android.content.res.Configuration;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.moengage.capacitor.MoECapacitorCorePlugin;
import com.moengage.capacitor.MoECapacitorHelper;
public class MainActivity extends BridgeActivity {
@Override public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
MoECapacitorHelper.INSTANCE.onConfigurationChanged();
}
}
Call MoEngage plugin's orientation change API
Call the below API to notify SDK on orientation change.
import { MoECapacitorCore } from 'capacitor-moengage-core';
MoECapacitorCore.onOrientationChanged();