Event callbacks

Prev Next

The Mapp Engage Flutter plugin uses static callback properties to deliver certain SDK events back to your Flutter application. This is especially important for push interactions, in-app messaging, inbox delivery, deep linking, and custom link handling.

How callbacks work

Callbacks are assigned directly on MappSdk as static properties. When the corresponding SDK event occurs, the assigned handler is invoked with the event payload.

MappSdk.handledPushOpen = (dynamic arguments) {
  print('Push opened: $arguments');
};

Because some events may occur early in the application lifecycle, assign callback handlers before calling engage().


Assign callbacks before initialization

To avoid missing early events, define the required callback handlers before initializing the SDK.

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  MappSdk.handledRemoteNotification = (dynamic arguments) {
    print('Push received: $arguments');
  };

  MappSdk.handledPushOpen = (dynamic arguments) {
    print('Push opened: $arguments');
  };

  await MappSdk.engage(
    'YOUR_SDK_KEY',
    'YOUR_GOOGLE_PROJECT_ID',
    SERVER.L3,
    'YOUR_APP_ID',
    'YOUR_TENANT_ID',
  );

  runApp(MyApp());
}

Push callbacks

Use these callbacks to react to incoming push notifications and user interactions.

MappSdk.handledRemoteNotification = (dynamic arguments) {
  // Fired when a push notification is received
};

MappSdk.handledPushOpen = (dynamic arguments) {
  // Fired when the user taps a notification
};

MappSdk.handledPushDismiss = (dynamic arguments) {
  // Fired when a notification is dismissed
};

MappSdk.handledPushSilent = (dynamic arguments) {
  // Fired for silent or data-only pushes
};

MappSdk.handledRichContent = (dynamic arguments) {
  // Fired when rich push media is available
};

Callback

Platform

Description

handledRemoteNotification

Android, iOS

Triggered when a push notification is received.

handledPushOpen

Android, iOS

Triggered when the user opens a notification.

handledPushDismiss

Android

Triggered when a notification is dismissed without being opened.

handledPushSilent

Android

Triggered for silent or data-only push delivery.

handledRichContent

Android, iOS

Triggered when rich push media becomes available.


In-app and inbox callbacks

Use these callbacks when your app relies on event-driven in-app messaging or inbox delivery.

MappSdk.didReceiveInappMessageWithIdentifier = (dynamic arguments) {
  // Fired when an in-app message is ready to display
};

MappSdk.didReceiveInBoxMessage = (dynamic arguments) {
  // Fired with a single inbox message result
};

MappSdk.didReceiveInBoxMessages = (dynamic arguments) {
  // Fired with all inbox messages
};

MappSdk.inAppCallFailedWithResponse = (dynamic arguments) {
  // Fired when an in-app API call fails
};

Callback

Platform

Description

didReceiveInappMessageWithIdentifier

Android, iOS

Triggered when an in-app message is ready to display.

didReceiveInBoxMessage

iOS

Triggered when a single inbox message is delivered.

didReceiveInBoxMessages

iOS

Triggered when multiple inbox messages are delivered.

inAppCallFailedWithResponse

Android, iOS

Triggered when an in-app API call fails.


Deep link and custom link callbacks

Use these callbacks to respond to link actions delivered by push notifications or in-app messaging.

MappSdk.didReceiveDeepLinkWithIdentifier = (dynamic arguments) {
  final String url = arguments.toString();
  // Parse and route the URL in your app
};

MappSdk.didReceiveCustomLinkWithIdentifier = (dynamic arguments) {
  // Handle a custom link action
};

Callback

Platform

Description

didReceiveDeepLinkWithIdentifier

Android, iOS

Triggered when a deep link is received.

didReceiveCustomLinkWithIdentifier

Android, iOS

Triggered when a custom link action is received.


Working with callback payloads

Callback payloads are passed as dynamic. Parse them according to your application needs.

  • Read push payload data

  • Handle deep links

  • Update UI state

  • Log message interactions


Platform differences

  • handledPushDismiss is Android-only

  • handledPushSilent is Android-only

  • Inbox delivery on iOS is event-based


Best practices

  • Assign callbacks before initialization

  • Keep handlers lightweight

  • Use a central navigation layer for routing

  • Handle platform differences explicitly