Flutter SDK Methods
Initialization
Mindbox.instance.init
Mindbox.instance.initCreate a configuration and initialize the SDK:
final config = Configuration(
domain: "domain API Maestra",
endpointIos: "endpoint for iOS",
endpointAndroid: "endpoint for Android",
subscribeCustomerIfCreated: true,
);
Mindbox.instance.init(configuration: config);
Maestra’s Domain APIUse
api.maestra.ioto send requests to Maestra’s API.
Retrieving Data from the SDK
getDeviceUUID
Retrieves the device UUID after it has been assigned. The method can be called at any time, but it returns a string via the callback only after initialization is complete.
Mindbox.instance.getDeviceUUID((uuid) {
print(uuid);
});getToken
Retrieves the token (APNS/FMS) after it has been assigned. The method can be called at any time, but it returns a string via the callback only after initialization is complete.
Mindbox.instance.getToken((token) {
print(token);
});sdkVersion
The property containing the current SDK version.
Mindbox.instance.nativeSdkVersionHandling Notification Clicks
onPushClickReceived
Subscribes to notification click events. The provided callback is triggered when the user taps a notification and the app is launched.
The callback receives the link and payload from the notification. Button taps return the button link; body taps return the body link.
Mindbox.instance.onPushClickReceived((link, payload) {
switch (link) {
case 'mindbox.cloud':
Navigator.push(context,
MaterialPageRoute(builder: (_) => ContentPage()));
break;
case 'mindbox.cloud/user':
Navigator.push(context,
MaterialPageRoute(builder: (_) => ProfilePage()));
break;
default:
Navigator.push(context,
MaterialPageRoute(builder: (_) => HomePage()));
}
});Event tracking
Event tracking in Maestra is handled through API Methods configured in the project interface.
Each method can run in one of two modes:
- Asynchronous — the Maestra API returns a 200 response as soon as the data is received. Processing continues in the background.
- Synchronous — the Maestra API starts processing the request immediately and returns the actual processing status.
For more details, see the article Sending events via the iOS SDK.
executeAsyncOperation
Asynchronous method execution.
Mindbox.instance.executeAsyncOperation(
operationSystemName: '<method system name>',
operationBody: {
<Map<String, dynamic> with data>
},
);executeSyncOperation
Synchronous method execution. The data is returned via the provided callbacks.
Mindbox.instance.executeSyncOperation(
operationSystemName: '<method system name>',
operationBody: {
<Map<String, dynamic> with data>
},
onSuccess: (data) {
// Handle a successful response
},
onError: (error) {
// Handle an error
},
);Logging Configuration
To control what the Mindbox SDK logs to the console, use the setLogLevel method.
Logs are written only in debug builds. In production mode, the Mindbox SDK does not output anything to the console.
Mindbox.instance.setLogLevel(logLevel: LogLevel.debug);Available values:
- LogLevel.verbose
- LogLevel.debug
- LogLevel.info
- LogLevel.warn
- LogLevel.error
- LogLevel.none
registerInAppCallbacks
Use this method to implement custom click handling and close the in-app message. For more details, see the following section.
Mindbox.instance.registerInAppCallbacks(inAppCallbacks: [
CustomInAppCallback(
clickHandler: (id, redirectUrl, payload) {
print(id);
print(redirectUrl);
print(payload);
},
dismissedHandler: (id) {
print(id);
},
),
]);refreshNotificationPermissionStatus (since 2.14.3)
This method is used to update the notification permission status.
Mindbox.instance.refreshNotificationPermissionStatus()Future<void> requestPermissions() async {
final isDenied = await Permission.notification.isDenied;
if (isDenied) {
final PermissionStatus status =
await Permission.notification.request();
Mindbox.instance.refreshNotificationPermissionStatus()
}
}Updated 7 months ago

