Flutter

Flutter listeners

NOTE: Android, Flutter SDK versions earlier than 3.0.0: the listeners on this page receive callbacks only if your MainActivity calls SyneriseMethodChannel.configureChannel(flutterEngine) in the configureFlutterEngine method. See Installation and configuration. Starting with Flutter SDK 3.0.0, the SDK configures this channel itself.

NotificationsListener

A listener to handle actions from the notifications module.

Synerise.notifications.listener((listener) {
  // The following method is called when registration for Push Notifications is needed.
  listener.onRegistrationRequired = () {
    ...
  };
});

NOTE: After invoking onRegistrationRequired() function, you must invoke the Synerise.notifications.registerForNotifications(registrationToken, mobileAgreement) method again.



InjectorListener

A listener to handle URL and deeplink actions from the injector module.

Synerise.injector.listener((listener) {
  // The following method is called when Synerise handles URL action from campaign activities
  // Optional. If you do not set it, the SDK opens the URL itself.
  listener.onOpenUrl = (url, source) {
    ...
  };
  // The following method is called when Synerise handles deep link action from campaign activities
  // Optional. If you do not set it, the SDK opens the deep link itself.
  listener.onDeepLink = (deepLink, source) {
    ...
  };
});


InjectorInAppMessageListener

A listener to handle the states of in-app messages.

Synerise.injector.inAppMessageListener((listener) {
  // The following method is called after an in-app message appears
  listener.onPresent = (data) {
    ...
  };
  // The following method is called after an in-app message disappears
  listener.onHide = (data) {
    ...
  };
  // This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
  listener.onOpenUrl = (data, url) {
      ...
  };
  // This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
  listener.onDeepLink = (data, deepLink) {
    ...
  };
  // This method is called when the
  // SRInApp.handleCustomAction(name, params) method is used in an in-app message.
  // parameters is a Map<String, String>.
  listener.onCustomAction = (data, name, parameters) {
    ...
  };
  // This method is called when the SRInApp.customMethod(name, params) method is used in an in-app message.
  // Resolve the completion exactly once, with success or failure.
  // If you do not set it, the SDK rejects the JS Promise.
  listener.onCustomMethod = (data, name, parameters, completion) {
    completion.success(null);
  };
});


InjectorInlineInAppMessageListener

A listener to handle actions from inline in-app messages and to receive widgets created by the SDK for event-triggered campaigns. Remove it with Synerise.injector.removeInlineInAppListener()

Synerise.injector.inlineInAppMessageListener((listener) {
  // This method is called when the SDK creates a ready-to-display widget
  // after an event-based trigger for a placement with no mounted widget.
  listener.onInlineInAppAvailable = (view, data) {
    ...
  };
  // This method is called when the SRInApp.openUrl(url) method is used in an inline in-app message.
  listener.onOpenUrl = (data, url) {
    ...
  };
  // This method is called when the SRInApp.openDeeplink(url) method is used in an inline in-app message.
  listener.onDeepLink = (data, deepLink) {
    ...
  };
  // This method is called when the
  // SRInApp.handleCustomAction(name, params) method is used in an inline in-app message.
  // parameters is a Map<String, dynamic>.
  listener.onCustomAction = (data, name, parameters) {
    ...
  };
  // This method is called when the SRInApp.customMethod(name, params) method is used in an inline in-app message.
  // Resolve the completion exactly once, with success or failure.
  listener.onCustomMethod = (data, name, parameters, completion) {
    completion.success(null);
  };
});

The view passed to onInlineInAppAvailable has no callbacks. To receive callbacks for this campaign, mount your own InlineInAppView with the same placement key and the adoptViewId of the delivered view:

InlineInAppView(
  placementKey: data.placementKey,
  adoptViewId: view.adoptViewId,
  onSizeChanged: (data, size) {
    // Update the layout
  },
)


InjectorWalkthroughListener

NOTE: InjectorWalkthroughListener was removed in SDK version 2.0.0.



InjectorBannerListener

NOTE: InjectorBannerListener was removed in SDK version 2.0.0.

Canonical URL: https://hub.synerise.com/developers/mobile-sdk/listeners-and-delegates/flutter-listeners