Set Injector listener
This method sets callbacks for an injector module.
Declared In:
lib/modules/injector/injector_impl.dart
Related To:
InjectorListener
Class:
InjectorImpl
Declaration:
void listener(InjectorListenerFunction listenerFunction)
Discussion:
Learn more about the methods and their purpose of this listener here.
Set In-App Message listener
This method sets callbacks for in-app message campaigns.
Declared In:
lib/modules/injector/injector_impl.dart
Related To:
InjectorInAppMessageListener
Class:
InjectorImpl
Declaration:
void inAppMessageListener(InjectorInAppMessageListenerFunction listenerFunction)
Discussion:
Learn more about the methods and their purpose of this listener here.
Set Inline In-App Message listener
This method sets callbacks for inline in-app message campaigns and enables the native global inline in-app listener.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 6.0.0 | 6.15.0 | 2.0.1 | 3.0.0 |
Declared In:
lib/modules/injector/injector_impl.dart
Related To:
InjectorInlineInAppMessageListener
Class:
InjectorImpl
Declaration:
void inlineInAppMessageListener(InjectorInlineInAppMessageListenerFunction listenerFunction)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| listenerFunction | InjectorInlineInAppMessageListenerFunction | yes | - | Function that receives the InjectorInlineInAppMessageListener object and assigns its callbacks |
Return Value:
No value is returned.
Discussion:
Learn more about this listener's methods and their purpose here.
The listener handles actions from inline in-app messages (URL, deeplink, custom action, custom method) and delivers widgets created by the SDK for event-triggered campaigns with no mounted widget. To disable the native listener, call removeInlineInAppListener()
Example:
Synerise.injector.inlineInAppMessageListener((listener) {
listener.onInlineInAppAvailable = (view, data) {
// Mount `view` for data.placementKey in your widget tree
};
listener.onOpenUrl = (data, url) {
//...
};
listener.onDeepLink = (data, deepLink) {
//...
};
listener.onCustomAction = (data, name, parameters) {
//...
};
listener.onCustomMethod = (data, name, parameters, completion) {
completion.success(null);
};
});
Remove Inline In-App Message listener
This method removes the native global inline in-app message listener.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | n/a | 6.15.0 | n/a | 3.0.0 |
| Declared In: | ||||
| lib/modules/injector/injector_impl.dart |
Related To:
InjectorInlineInAppMessageListener
Class:
InjectorImpl
Declaration:
void removeInlineInAppListener()
Return Value:
No value is returned.
Discussion:
Call it when the screen that registered the listener is disposed. After the call, the SDK no longer delivers inline in-app message callbacks to the Dart side until inlineInAppMessageListener(...) is called again.
Example:
@override
void dispose() {
Synerise.injector.removeInlineInAppListener();
super.dispose();
}
Render inline in-app message
This method triggers rendering of an inline in-app message in the widget. Use it for campaigns with the on-demand trigger.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 6.0.0 | 6.15.0 | 2.0.1 | 3.0.0 |
| Declared In: | ||||
| lib/modules/injector/inapp/inline_in_app_view.dart |
Related To:
InlineInAppView
Class:
InlineInAppViewController
Declaration:
Future<void> render()
Return Value:
A Future that completes when the command is passed to the native view. The rendering result is reported through the widget callbacks (onLoaded, onUpdated or onFailed), not through the returned Future
Discussion:
Pass the controller as the controller parameter of InlineInAppView. The method matches only campaigns with the on-demand trigger for the widget's placement key. If the native view is not attached yet, the render is deferred and applied as soon as the view becomes ready, so the method can be called right after building the widget.
Example:
final InlineInAppViewController _controller = InlineInAppViewController();
SizedBox(
height: 100,
child: InlineInAppView(
placementKey: 'home_top_banner',
controller: _controller,
),
)
// Later, for example on a button press:
_controller.render();
Release inline in-app message view
This method tears the inline in-app message down (destroys the web view and clears the campaign data) while the widget stays mounted.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | n/a | 6.15.0 | 2.0.1 | 3.0.0 |
| Declared In: | ||||
| lib/modules/injector/inapp/inline_in_app_view.dart |
Related To:
InlineInAppView
Class:
InlineInAppViewController
Declaration:
Future<void> release()
Return Value:
A Future that completes when the command is passed to the native view.
Discussion:
Use it when you keep the widget mounted but want to free the placement, for example after the onRemove callback. Removing the widget from the tree disposes the platform view and releases the native view automatically, so no call is needed in that case.
Example:
InlineInAppView(
placementKey: 'home_top_banner',
controller: _controller,
onRemove: (data) {
setState(() => _componentHeight = 0);
_controller.release();
},
)
Check if inline in-app message is rendered
This method checks if the widget currently shows a rendered inline in-app message.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 6.0.0 | 6.15.0 | 2.0.1 | 3.0.0 |
| Declared In: | ||||
| lib/modules/injector/inapp/inline_in_app_view.dart |
Related To:
InlineInAppView
Class:
InlineInAppViewController
Declaration:
Future<bool> isRendered()
Return Value:
true if the widget shows a rendered campaign, otherwise false. It also returns false when the widget is not mounted.
Example:
final bool isRendered = await _controller.isRendered();
Get inline in-app message data
This method returns the data of the inline in-app message currently shown in the widget.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 6.0.0 | 6.15.0 | 2.0.1 | 3.0.0 |
| Declared In: | ||||
| lib/modules/injector/inapp/inline_in_app_view.dart |
Related To:
InlineInAppView
InlineInAppMessageData
Class:
InlineInAppViewController
Declaration:
Future<InlineInAppMessageData?> getData()
Return Value:
An InlineInAppMessageData object, or null when the widget is not mounted or holds no rendered campaign.
Example:
final InlineInAppMessageData? data = await _controller.getData();
if (data != null) {
debugPrint('${data.campaignHash} ${data.placementKey}');
}
In-app context
A map sent to the backend for server-side Jinja evaluation in in-app message templates.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 5.14.0 | 6.14.0 | 1.10.0 | 2.11.0 |
| Declared In: | ||||
| lib/modules/injector/injector_impl.dart |
Related To:
InAppContextKey
Class:
InjectorImpl
Declaration:
Map<String, dynamic> inAppContext
Discussion:
A map sent to the backend for server-side Jinja evaluation in in-app message templates. Use InAppContextKey.jinjavaContext as a key to pass Jinja context variables. Changes are pushed to the SDK automatically; call notifyInAppContextChange() to re-evaluate active inline in-app messages with the updated context.
Example:
Synerise.injector.inAppContext[InAppContextKey.jinjavaContext] = {
'firstName': 'Anna',
'cartValue': 199.99,
};
Synerise.injector.notifyInAppContextChange();
Notify in-app context change
Notifies active in-app messages that the application context has changed.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 5.14.0 | 6.14.0 | 1.10.0 | 2.11.0 |
| Declared In: | ||||
| lib/modules/injector/injector_impl.dart |
Class:
InjectorImpl
Declaration:
void notifyInAppContextChange()
Parameters:
No parameters.
Return Value:
No value is returned.
Discussion:
Notifies active in-app messages that the application context has changed. Call it after updating inAppContext so that inline in-app messages re-evaluate their templates with the new values.
Example:
Synerise.injector.inAppContext[InAppContextKey.jinjavaContext] = {
'tier': 'gold',
};
Synerise.injector.notifyInAppContextChange();
Close in-app message
Closes an in-app message and sends an inApp.discard event.
Usage examples:
- Closing a top bar or bottom bar when the user taps outside the in-app area.
- Automatically dismissing messages when navigating away from a screen.
- Controlling in-app visibility based on app logic for a smoother user experience.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 5.7.0 | 6.7.0 | 1.5.0 | 2.5.0 |
Declared In:
lib/modules/injector/injector_impl.dart
Class:
InjectorImpl
Declaration:
void closeInAppMessage(String campaignHash)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| campaignHash | String | yes | - | Unique identifier of the in-app campaign |
Register for push notifications
This method passes the Firebase Token to Synerise for notifications.
- You should call this method every time the user changes the system or application consent for notifications.
- The API key must have the
API_PERSONAL_DEVICE_CLIENT_UPDATEpermission from the Client group. - If the registration fails, the SDK requests a token update again by a listener/delegate method (Android, iOS, React Native, Flutter).
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<void> registerForNotifications(String registrationToken,
{bool? mobileAgreement,
required void Function() onSuccess,
required void Function(SyneriseError error) onError})
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| registrationToken | String | yes | - | Firebase Token |
| mobileAgreement | bool | no | null | Agreement (consent) for receiving mobile push campaigns |
| onSuccess | Function() | yes | - | Function to be executed when the operation is completed successfully |
| onError | Function(SyneriseError error) | yes | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
NOTE: This method also allows using the registerForPushWithoutAgreement native method.
The registerForPushWithoutAgreement method will be used when the mobileAgreement parameter is not filled.
Example:
FirebaseMessaging.instance.onTokenRefresh.listen((event) {
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
firebaseToken = token;
Synerise.notifications.registerForNotifications(
firebaseToken!,
mobileAgreement: true,
onSuccess: () {},
onError: (error) {},
);
}
});
});
Declaration:
Future<void> registerForNotifications(String registrationToken, [bool? mobileAgreement])
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| registrationToken | String | yes | - | Firebase Token |
| mobileAgreement | bool | no | null | Agreement (consent) for receiving mobile push campaigns |
Return Value:
No value is returned.
NOTE: This method also allows to use registerForPushWithoutAgreement native method.
The registerForPushWithoutAgreement method will be used when the mobileAgreement parameter is not filled.
Example:
FirebaseMessaging.instance.onTokenRefresh.listen((event) {
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
firebaseToken = token;
Synerise.notifications.registerForNotifications(
firebaseToken!,
mobileAgreement: true,
);
}
});
});
Handle Synerise push notification
This method handles a notification payload and starts activity.
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> handleNotification(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map<String, dynamic> | yes | - | Notification’s key-value data object |
Return Value:
true if the notification is handled properly.
Example:
FirebaseMessaging.onMessage.listen((RemoteMessage message,) {
Synerise.notifications.handleNotification(message.toMap());
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
Synerise.notifications.handleNotificationClick(message.toMap());
});
Handle Synerise push notification click
This method handles a notification payload with a user interaction and starts activity.
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> handleNotificationClick(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map<String, dynamic> | yes | - | Notification’s key-value data object |
Return Value:
true if the notification is handled properly.
Example:
FirebaseMessaging.onMessage.listen((RemoteMessage message,) {
Synerise.notifications.handleNotification(message.toMap());
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
Synerise.notifications.handleNotificationClick(message.toMap());
});
Check if push notification is from Synerise
This method verifies if a notification was sent by Synerise.
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> isSyneriseNotification(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map | yes | - | Key-Value map of data |
Return Value:
true if the notification is provided by Synerise, otherwise returns false.
Example:
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(remoteMessageMap);
Check if push notification is a Simple Push Campaign
This method verifies if a notification’s sender is Synerise and if the notification is a Simple Push campaign
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> isSyneriseSimplePush(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map | yes | - | Key-Value map of data |
Return Value:
true if the notification is Synerise Simple Push provided by Synerise, otherwise returns false.
Example:
bool isSyneriseSimplePush = await Synerise.notifications.isSyneriseSimplePush(remoteMessageMap);
Check if push notification is a Silent Command
This method verifies if a notification’s sender is Synerise and if the notification is a Silent Command.
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> isSilentCommand(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map | yes | - | Key-Value map of data |
Return Value:
true if the notification is Synerise Silent Command provided by Synerise, otherwise returns false.
Example:
bool isSilentCommand = await Synerise.notifications.isSilentCommand(remoteMessageMap);
Check if push notification is a Silent SDK Command
This method verifies if a notification's sender is Synerise and if the notification is a Silent SDK Command.
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> isSilentSDKCommand(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map | yes | - | Key-Value map of data |
Return Value:
true if the notification is Synerise Silent SDK Command provided by Synerise, otherwise returns false.
Example:
bool isSilentSDKCommand = await Synerise.notifications.isSilentSDKCommand(remoteMessageMap);
Removed methods
Check if push notification is a Banner Campaign
This method verifies if a notification’s sender is Synerise and if the notification is a Banner campaign.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
Declared In:
lib/modules/notifications/notifications_impl.dart
Class:
NotificationsImpl
Declaration:
Future<bool> isSyneriseBanner(Map notification) async
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| notification | Map | yes | - | Key-Value map of data |
Return Value:
true if the notification is Synerise Banner provided by Synerise, otherwise returns false.
Example:
bool isSyneriseBanner = await Synerise.notifications.isSyneriseBanner(remoteMessageMap);
Get Walkthrough
This method fetches a walkthrough.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
NOTE: The API key must have the CAMPAIGN_BACKEND_CAMPAIGN_READ permission from the Campaign group.
Declared In:
lib/modules/injector/injector_impl.dart
Class:
InjectorImpl
Declaration:
void getWalkthrough()
Return Value:
No value is returned.
Example:
Synerise.injector.getWalkthrough();
Show Walkthrough
This method shows a walkthrough when it is loaded.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
Declared In:
lib/modules/injector/injector_impl.dart
Class:
InjectorImpl
Declaration:
void showWalkthrough()
Return Value:
No value is returned.
Example:
Synerise.injector.showWalkthrough();
Check if Walkthrough is loaded
This method checks if a walkthrough is loaded.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
Declared In:
lib/modules/injector/injector_impl.dart
Class:
InjectorImpl
Declaration:
Future<bool> isWalkthroughLoaded()
Return Value:
true if the walkthrough is loaded, otherwise returns false.
Example:
var isLoaded = await Synerise.injector.isWalkthroughLoaded();
Check if is loaded Walkthrough unique
This method checks if the walkthrough is unique compared to the previous one.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
Declared In:
lib/modules/injector/injector_impl.dart
Class:
InjectorImpl
Declaration:
Future<bool> isLoadedWalkthroughUnique()
Return Value:
true if the loaded walkthrough is unique, otherwise returns false.
Example:
var isLoaded = await Synerise.injector.isLoadedWalkthroughUnique();