InApp NATIV

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.

Show InApp

Call the below API to show an inApp campaign on a screen.

import 'package:moengage_flutter/moengage_flutter.dart';

final MoEngageFlutter _moengagePlugin = MoEngageFlutter();
_moengagePlugin.initialise();
_moengagePlugin.showInApp();

InApp Callbacks

We provide callbacks for inAppShown and inAppClicked events and you can register for the same as shown below.

import 'package:moengage_flutter/moengage_flutter.dart';
import 'package:moengage_flutter/inapp_campaign.dart';

  void _onInAppClick(InAppCampaign message) {
    print("This is a inapp click callback from native to flutter. Payload " +
        message.toString());
  }

  void _onInAppShown(InAppCampaign message) {
    print("This is a callback on inapp shown from native to flutter. Payload " +
        message.toString());
  }

  void _onInAppDismiss(InAppCampaign message) {
    print("This is a callback on inapp dismiss from native to flutter. Payload " +
        message.toString());
  }

  void _onInAppCustomAction(InAppCampaign message) {
    print("This is a callback on inapp custom action from native to flutter. Payload " +
        message.toString());
  }

  void _onInAppSelfHandle(InAppCampaign message) {
    print("This is a callback on inapp self handle from native to flutter. Payload " +
        message.toString());
  }

final MoEngageFlutter _moengagePlugin = MoEngageFlutter();
//Register for callbacks
    _moengagePlugin.setUpInAppCallbacks(
      onInAppClick: _onInAppClick,
      onInAppShown: _onInAppShown,
      onInAppDismiss: _onInAppDismiss,
      onInAppCustomAction: _onInAppCustomAction,
      onInAppSelfHandle: _onInAppSelfHandle
    );

InApp Payload

InApp Payload will be received in the below format:

class InAppCampaign {
    /// Unique identifier for each campaign.
  String campaignId;

  /// Campaign Name
  String campaignName;

  /// Native platform from which the callback was triggered.
  String platform;

  /// Instance of [NavigationAction]
  NavigationAction navigationAction;

  /// Instance of [SelfHandled]
  SelfHandled selfHandled;

  /// Instance of [CustomAction]
  CustomAction customAction;
}

class NavigationAction {
  /// Type of Navigation action.
  ///
  /// Possible value deep_linking or screen
  String navigationType;

  /// Deeplink Url or the Screen Name used for the action.
  String url;

  /// [Map] of Key-Value pairs entered on the MoEngage Platform for
  /// navigation action of the campaign.
  Map<String, dynamic> keyValuePairs;
}

class CustomAction {
  ///Key-Value Pair entered on the MoEngage Platform during campaign creation.
  Map<String, dynamic> keyValuePair;
}

class SelfHandled {
  /// Self handled campaign payload.
  String campaignContent;

  /// Interval after which in-app should be dismissed, unit - Seconds
  int dismissInterval;

  /// Should the campaign be dismissed by pressing the back button or using
  /// the back gesture. if the value is true campaign should be dismissed on
  /// back press.
  bool cancellable;
}

Handling Orientation Change

🚧

NOTE:

This is only for the Android platform.

Starting SDK version 4.1.0 in-apps are supported in both portrait and landscape modes.
SDK has to be notified when the device orientation changes for SDK to handle in-app display.

There are two ways to do it:

  1. Add the API call in the Android native part of your app
  2. 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.

public class MainActivity extends FlutterActivity {

  ...
    
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    MoEFlutterHelper.getInstance().onConfigurationChanged();
    ...
  }
  
  ...
}

Call MoEngage plugin's orientation change API

Call the below API to notify SDK on orientation change.

_moengagePlugin.onOrientationChanged();