Implement the plugin

For convenience, you should use mapp_sdk.dart and helper_classes.dart.

Initialising SDK

For the Initialization use this method as the first function in your application :

Future<String?> engage(String sdkKey, String googleProjectId,
      SERVER server, String appID, String tenantID)

@param {string} sdkKey - The SDK ID for your account.
@param {string} googleProjectId - The Google project id from your Firebase console for the chosen app.

googleProjectId - Can be empty String. It is not used, but it is here only for backward compatibility.

@param {string} server - The Server, which will be used for engagement, this info will be provided by account managers.
@param {string} tenantID - The ID which recognizes you at the Mapp Engage system, will be also provided by account managers.

iOS uses most information from AppoxeeCofig.plist as explained in the integration section, so you need to have that plist set up inside iOS project.

Server list:

Check if the device is registered in Mapp

    bool isRegistered = MappSdk.isReady()

 

Alias

Get device alias

MappSdk.getAlias().then(
          (String value) => {_showMyDialog("Show Alias", "Alias:", value)});

Set device alias

MappSdk.setAlias("some alias");

 

Device API

Get device info (_showMyDialog is just helper method which will display alert dialog with data)

MappSdk.getDeviceInfo().then((Map<String, dynamic>? map)
          {
            data=map!=null ? jsonEncode(map) : "null";
            _showMyDialog("Device info", "", data);
          });

 

Push API

Push Enabled

Check if the feature is enabled.

 MappSdk.isPushEnabled().then((bool value) =>
          {_showMyDialog("Show Device Information", "", value ? "YES" : "NO")});

 

Push toggle

Disable or enable push.

MappSdk.setPushEnabled(true);

Request permission to display notification (on Android 13 and higher only)

final result = await MappSdk.requestPermissionPostNotifications();
debugPrint("POST NOTIFICATION PERMISSION RESULT: " + result.toString());
if (!result) {
  _showMyDialog(
      "POST NOTIFICATION", "Permission result", "Permission was denied!");
}

Push notification received

Subscribe/listen for push received events:

void remoteNotificationHandler(dynamic arguments) {
    print("remote Notification received!");
    print(arguments);
  }
  
MappSdk.handledRemoteNotification =
        (dynamic arguments) => remoteNotificationHandler(arguments);

For iOS also is an available listener for rich messages:

void richContentHandler(dynamic arguments) {
    print("rich Content received!");
    print(arguments);
  }
MappSdk.handledRichContent =
        (dynamic arguments) => richContentHandler(arguments);

On Android some additional event handlers are available:

  void pushOpenedHandler(dynamic arguments) {
    print("Push opened!");
    print(arguments);
  }
  
  MappSdk.handledPushOpen = 
      (dynamic arguments) => pushOpenedHandler(arguments);
  void pushDismissedHandler(dynamic arguments) {
    print("Push dismissed!");
    print(arguments);
  }
  
  MappSdk.handledPushDismiss =
        (dynamic arguments) => pushDismissedHandler(arguments);
  void pushSilentHandler(dynamic arguments) {
    print("Push silent!");
    print(arguments);
  }
  
  MappSdk.handledPushSilent =
        (dynamic arguments) => pushSilentHandler(arguments);

Log out

@param{boolean} pushEnabled - while logging out sets the state of receiving push messages.

MappSdk.logOut(pushEnabled);

In-app API

Get Inbox Messages

To get inbox messages use Mapp.fetchInboxMessage()

if (Platform.isAndroid) {
    MappSdk.fetchInboxMessage().then((messages) {
      _showMyDialog("Inbox messages", "", messages);
    });
} else {
    MappSdk.fetchInboxMessage();
}

NOTE: Please, pay attention that on Android, messages should be received and handled in async .then() {} block. This is NOT posible on iOS.

Additional requirements for iOS only:

  void didReceiveInBoxMessagesHandler(dynamic arguments) {
    print("Inbox Messages received!");
    print(arguments);
  }
  
  MappSdk.didReceiveInBoxMessages =
    (dynamic arguments) => didReceiveInBoxMessagesHandler(arguments);

iOS uses events for inbox messages (didReceiveInBoxMessagesHandler )and cannot return them as promise.

Show In-App message

The method triggers an In-App message.
@param {string} event-specific DCM event trigger. 

MappSdk.triggerInApp("app_open")

 

Manage In-app messages

Inapp messages can be marked as read, unread or deleted.

@param{number} templateId

@param{string} eventId

MappSdk.inAppMarkAsRead(templateId: number, eventId: string);

MappSdk.inAppMarkAsUnRead(templateId: number, eventId: string);

MappSdk.inAppMarkAsDeleted(templateId: number, eventId: string);

 

Geo targeting API

For Android and iOS you need to add necessary statements at info.plist and capabilities section (iOS) and Android Manifest file.

Start geo targeting feature

MappSdk.startGeoFencing().then((status) {
        debugPrint("Start Geofencing status:" + status);
        // handle successfull start of geo targeting
      }).catchError((e) {
        debugPrint("Start Geofencing error:" + e.toString());
        // handle errors
      });

Stop geo targeting feature

MappSdk.stopGeoFencing().then((status) {
        debugPrint("Stop Geofencing status:" + status);
        // handle successfull stoping of geo targeting
      }).catchError((e) {
        debugPrint("Stop Geofencing error:" + e.toString());
        // handle errors
      });