MBMessages class

This is the main entry point to manage all the messages features of MBurger. To use create an instance of MBMessages and add it to the MBManager plugins. MBManager.shared.plugins = [MBMessages()]; You can pass other options described below in the init method described below.

Inheritance

Constructors

MBMessages({int messagesDelay = 1, bool automaticallyCheckMessagesAtStartup = true, bool debug = false, MBInAppMessageTheme themeForMessage(BuildContext, MBInAppMessage)?, dynamic onButtonPressed(MBInAppMessageButton)?})
Initializes an instance of MBMessages plugin @param messagesDelay The delayed (in seconds) used to delay the presenting of the message after a successful fetch. By default it's 1 second. @param automaticallyCheckMessagesAtStartup If the plugin should automatically check messages at startup. By default it's true. @param debug Settings this var to true will always display the messages returned by the api, even if they've been already showed. @param themeForMessage A theme used to define and override colors and fonts of in-app messages. @param onButtonPressed Callback called when a button of an in-app message is tapped. Use this to bring you user to the correct screen, based on the button settings.

Properties

automaticallyCheckMessagesAtStartup bool
If the plugin should automatically check messages at startup. If you set this value to false you can call checkMessages() to manually check the messages.
getter/setter pair
debug bool
Settings this var to true will always display the messages returned by the api, even if they've been already showed.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
messagesDelay int
The delayed (in seconds) used to delay the presenting of the message after a successful fetch. The default is 1 second.
getter/setter pair
onButtonPressed ↔ (dynamic Function(MBInAppMessageButton)?)
Use this function to receive a callback when a button is pressed
getter/setter pair
order int
The order of startup for this plugin, in MBurger
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startupOrder int
The order of startup of plugins
getter/setter pairinherited
themeForMessage ↔ (MBInAppMessageTheme Function(BuildContext, MBInAppMessage)?)
Use this function to provide a theme for in-app messages.
getter/setter pair

Methods

checkMessages() Future<void>
This method checks the messages from the server and shows them, if needed. It's called automatically at startup, but it can be called to force the check.
locationDataUpdated(double latitude, double longitude) → void
inherited
messagesReceived(List messages, bool fromStartup) → void
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
presentMessages(List<MBMessage> messages) → dynamic
Presents in app messages to the user. @param messages In app messages that will be presented.
startupBlock() Future<void>
The function run at startup by MBurger, initializes the plugin and do the startup work. It increments the session number and updates the metadata.
override
tagChanged(String tag, {String? value}) → void
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

contextCallback ↔ (BuildContext Function()?)
A function to provide the BuildContext to show in-app messages. To present in-app messages MBMessages uses the showDialog function that needs a BuildContext. If you use a MBMessagesBuilder you don't have to set this and it will be handled automatically.
getter/setter pair
onToken ↔ (dynamic Function(String)?)
Callback called when a token is retrieved from APNS or FCM
getter/setter pair
pushToken String
Returns the pushToken of the push notifications plugin of MBurger. This will return the token of the MPush SDK. If you need help setting up the push notifications go to the MPush documentation.
getter/setter pair

Static Methods

addCustomReplacements({required Map<String, String>? customReplacements}) Future<void>
Configures the MBPush plugin with custom replacements map made of Key -> String to replace Value -> String to add
configurePush({required dynamic onNotificationArrival(Map<String, dynamic>), required dynamic onNotificationTap(Map<String, dynamic>), required MPAndroidNotificationsSettings androidNotificationsSettings}) → dynamic
Configures the MBPush plugin with the callbacks.
devicePushTopic() Future<MPTopic>
A push topic that represents this device, used to send a push to only this device. @returns a future that completes with the device push topic.
getCustomReplacements() Future<Map<String, String>?>
Obtain current saved custom replacements If there are no maps saved it will return null
launchNotification() Future<Map<String, dynamic>?>
The notification that launched the app, if present, otherwise null.
projectPushTopic() Future<MPTopic>
A push topic that represents all devices, used to send a push to all apps. @returns a future that completes with the project push topic.
registerDevice(String token) Future<void>
Register a device token.
registerToTopic(MPTopic topic) Future<void>
Register the current device to a topic.
registerToTopics(List<MPTopic> topics) Future<void>
Register the current device to an array of topics.
removeCustomReplacements() Future<void>
Clears the custom replacements from MBPush plugin
requestToken() Future<void>
Requests the token to APNS & GCM.
unregisterFromAllTopics() Future<void>
Unregister the current device from all topics it is registred to.
unregisterFromTopic(String topic) Future<void>
Unregister the current device from a topic, the topic is matched using the code of the topic.
unregisterFromTopics(List<String> topics) Future<void>
Unregister the current device from an array of topics, the topics are matched using the code of the topic.