MBurger Engagement Platform
User GuideHeadless CMSEngagement Platform
  • 🍔MBurger Engagement Platform 🍔
  • 🍏 iOS Docs
    • Messages
      • Installation
      • Initialization
      • Push notifications
        • Rich Notifications
      • Stylize in app messages
      • Message Metrics
    • Audience
      • Installation
      • Initialization
      • Tracked data
      • Tags
      • Identify a user
      • Location
    • Automation
      • Installation
      • Initialization
      • Triggers
      • Send events
      • View Tracking
  • 📱Android Docs
    • Messages
      • Prerequisites for Push Notifications
      • Installation
      • Initialization
      • Stylization and parameters
      • Push notifications
      • Message Metrics
    • Audience
      • Installation
      • Initialization
      • Tracked data
      • Tags
      • Custom Id
      • Mobile User Id
      • Location Data
    • Automation
      • Installation
      • Initialization
      • Triggers
      • Add events
      • View Tracking
      • Stop/Pause tracking
  • 🔷Flutter Docs
    • Messages
      • Installation
      • Initialization
      • Stylize in app messages
      • Push notifications
        • Rich Notifications
      • Message Metrics
    • Audience
      • Installation
      • Initialization
      • Tracked data
      • Tags
      • Custom Id
      • Mobile User Id
      • Location Data
    • Automation
      • Installation
      • Initialization
      • Triggers
      • Send events
      • View Tracking
Powered by GitBook
On this page

Was this helpful?

  1. Flutter Docs
  2. Messages

Initialization

To initialize the SDK you have to add MBMessages to the array of plugins of MBurger.

MBManager.shared.apiToken = 'YOUR_API_TOKEN';
MBManager.shared.plugins = [MBMessages()];

To show in app message correctly you have to embed your main widget in a MBMessagesBuilder like this:

@override
Widget build(BuildContext context) {
return MaterialApp(
  ...
    home: MBMessagesBuilder(
      child: Scaffold(
        ...
      ),
    ),
  );
}

Why? To present in app messages MBMessages uses the showDialog function that needs a BuildContext. Embedding your main Scaffold in a MBMessagesBuilder let the SDK know always what context to use to show in app messages.

Initialize MBMessages with parameters

You can set a couples of parameters when initializing the MBMessages plugin:

MBMessages messagesPlugin = MBMessages(
  messagesDelay: 1,
  automaticallyCheckMessagesAtStartup: true,
  debug: false,
  themeForMessage: (message) => MBInAppMessageTheme(),
  onButtonPressed: (button) => _buttonPressed(button),
);
  • messagesDelay: it's the time after which the messages will be displayed once fetched

  • automaticallyCheckMessagesAtStartup: if the plugin should automatically check messages at startup. By default it's true.

  • debug: if this is set to true, all the message returned by the server will be displayed, if this is set to false a message will appear only once for app installation. This is false by default

  • themeForMessage: a function to provide a message theme (colors and fonts) for in app messages.

  • onButtonPressed: a callback called when a button of an in app message iis pressed.

PreviousInstallationNextStylize in app messages

Last updated 4 years ago

Was this helpful?

🔷