Set Injector listener
This method sets callbacks for an injector module.
Declared In:
lib/main/modules/InjectorModule.js
Related To:
ClientStateChangeListener
Class:
InjectorModule
Declaration:
public setListener(listener: IInjectorListener)
Discussion:
Learn more about the methods and the purpose of this listener here.
Set In-App Message listener
This method sets callbacks for in-app message campaigns.
Declared In:
lib/main/modules/InjectorModule.js
Related To:
InjectorInAppMessageListener
Class:
InjectorModule
Declaration:
public setInAppMessageListener(listener: IInjectorInAppMessageListener)
Discussion:
Learn more about the methods and the purpose of this listener here.
Set Inline In-App Message listener
This method sets callbacks for inline in-app message campaigns.
| 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/main/modules/InjectorModule.js
Related To:
InjectorInlineInAppMessageListener
Class:
InjectorModule
Declaration:
public setInlineInAppMessageListener(listener: IInlineInAppMessageListener)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| listener | IInlineInAppMessageListener | yes | - | Object that implements the inline in-app message listener |
Return Value:
No value is returned.
Discussion:
Learn more about the methods and the purpose of this listener here.
The listener handles actions from inline in-app messages (URL, deeplink, custom action, custom method) and delivers components created by the SDK for event-triggered campaigns with no mounted component. Setting a new listener replaces the previous one.
Example:
Synerise.Injector.setInlineInAppMessageListener({
onInlineInAppAvailable: (view, data) => {
// Mount `view` for data.placementKey in your component tree
},
onOpenUrl: (data, url) => {
//...
},
onDeepLink: (data, deepLink) => {
//...
},
onCustomAction: (data, name, parameters) => {
//...
},
onCustomMethod: (data, name, parameters, completion) => {
completion.success({});
},
});
Render inline in-app message
This method triggers rendering of an inline in-app message in the component. 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/main/modules/inapp/InlineInAppView.js |
Related To:
InlineInAppView
Class:
InlineInAppViewHandle
Declaration:
render(): void
Return Value:
No value is returned.
Discussion:
Call it on the component ref. The method matches only campaigns with the on-demand trigger for the component's placement key. The result is reported through the component callbacks (onLoaded, onUpdated or onFailed). The ref is available after the component is mounted.
Example:
const inlineViewRef = useRef(null);
<InlineInAppView
ref={inlineViewRef}
placementKey="home_top_banner"
style={{ width: '100%', height: '100%' }}
/>
// Later, for example on a button press:
inlineViewRef.current?.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 component 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/main/modules/inapp/InlineInAppView.js |
Related To:
InlineInAppView
Class:
InlineInAppViewHandle
Declaration:
release(): void
Return Value:
No value is returned.
Discussion:
Use it when you keep the component mounted but want to free the placement, for example after the onRemove callback. Unmounting the component releases the native view automatically, so no call is needed in that case.
Example:
<InlineInAppView
ref={inlineViewRef}
placementKey="home_top_banner"
style={{ width: '100%', height: '100%' }}
onRemove={(data) => {
setContainerHeight(0);
inlineViewRef.current?.release();
}}
/>
Check if inline in-app message is rendered
This method checks if the component 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/main/modules/inapp/InlineInAppView.js |
Related To:
InlineInAppView
Class:
InlineInAppViewHandle
Declaration:
isRendered(): Promise<boolean>
Return Value:
A Promise that resolves to true if the component shows a rendered campaign, otherwise false. It also resolves to false when the component is not mounted.
Example:
const isRendered = await inlineViewRef.current?.isRendered();
Get inline in-app message data
This method returns the data of the inline in-app message currently shown in the component.
| 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/main/modules/inapp/InlineInAppView.js |
Related To:
InlineInAppView
InlineInAppMessageData
Class:
InlineInAppViewHandle
Declaration:
getData(): Promise<InlineInAppMessageData | null>
Return Value:
A Promise that resolves to an InlineInAppMessageData object, or null when the component is not mounted or holds no rendered campaign.
Example:
const data = await inlineViewRef.current?.getData();
if (data != null) {
console.log(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/main/modules/InjectorModule.js |
Related To:
InAppContextKey
Class:
InjectorModule
Declaration:
get inAppContext(): { [key: string]: any }
set inAppContext(context: { [key: string]: any })
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. Call notifyInAppContextChange() after updating it to re-evaluate active inline in-app messages with the new values.
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/main/modules/InjectorModule.js |
Class:
InjectorModule
Declaration:
public notifyInAppContextChange(): void
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. The SDK calls the SRInApp.onContextFromApp(context) JS callback with the current context in every displayed in-app message. The campaign is not re-rendered: server-side Jinja evaluation uses the InAppContextKey.JinjavaContext value only when a message is rendered.
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/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public closeInAppMessage(campaignHash: string)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| campaignHash | string | yes | - | Unique identifier of the in-app campaign |
Set Notifications listener
This method sets callbacks for notifications module.
Declared In:
lib/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public setListener(listener: INotificationsListener)
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/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public registerForNotifications(registrationToken: string, mobileAgreement: boolean | null, onSuccess: () => void, onError: (error: Error) => void)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| registrationToken | string | yes | - | Firebase Token |
| mobileAgreement | boolean | false | null | Agreement (consent) for mobile push campaigns |
| onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
| onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
// If you integrate Firebase Messaging in the native part of app
Synerise.Notifications.setListener({
onRegistrationToken: function(registrationToken) {
Synerise.Notifications.registerForNotifications(registrationToken, true, function(){
//success
}, function() {
//failure
});
},
onNotification: function(payload) {
//...
}
//...
//other listener's methods
});
// Or if you want to use Firebase Messaging in react native
Synerise.Notifications.registerForNotifications("YOUR_FIREBASE_TOKEN", true, function(){
//success
}, function() {
//failure
});
Check if push notification is from Synerise
This method verifies if a notification was sent by Synerise.
Declared In:
lib/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public isSyneriseNotification(payload: object): boolean
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
true if a notification was sent by Synerise, otherwise false.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSyneriseNotification(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
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/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public isSyneriseSimplePush(payload: object): boolean
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
true if a notification is a Simple Push, otherwise false.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSyneriseSimplePush(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
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/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public isSilentCommand(payload: object): boolean
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
true if a notification is a Silent Command, otherwise false.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSilentCommand(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
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/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public isSilentSDKCommand(payload: object): boolean
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
true if a notification is a Silent SDK Command, otherwise false.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSilentSDKCommand(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
Check if push notification is encrypted
This method verifies if a notification is encrypted.
Declared In:
lib/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public isNotificationEncrypted(payload: object): boolean
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
true if a notification is encrypted, otherwise false.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isNotificationEncrypted(payload)) {
Synerise.Notifications.decryptNotification(payload);
}
}
//...
//other listener's methods
});
Decrypt push notification
This method decrypts the notification payload.
NOTE: If the notification is not encrypted, the method returns the raw payload.
NOTE: If a notification is not decrypted successfully, the method returns nil.
Declared In:
lib/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public decryptNotification(payload: object): object | null
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
Notification’s key-value data object with decrypted content
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
let data = Synerise.Notifications.decryptNotification(payload)
// custom notification implementation
}
//...
//other listener's methods
});
Handle Synerise push notification
This method handles a notification payload and starts activity.
Declared In:
lib/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public handleNotification(payload: object, actionIdentifier: string | null)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
No value is returned.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
Synerise.Notifications.handleNotification(payload);
}
//...
//other listener's methods
});
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/main/modules/NotificationsModule.js
Class:
NotificationsModule
Declaration:
public isSyneriseBanner(payload: object): boolean
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| payload | object | yes | - | Notification's key-value data object |
Return Value:
true if a notification is a Banner, otherwise false.
Example:
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSyneriseBanner(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
Fetch Banners
This method fetches banners set for mobile campaigns and caches the valid ones.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 4.6.0 | 4.7.0 | 0.12.0 | n/a |
NOTE: This method was removed in SDK version 0.12.0.
Declared In:
lib/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public fetchBanners(onSuccess, onError)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| onSuccess | Function | no | - | Function to be executed when the operation is completed successfully |
| onError | Function | no | - | Function to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Get Banners
This method provides valid banners directly from SDK cache.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 4.6.0 | 4.7.0 | 0.12.0 | n/a |
NOTE: This method was removed in SDK version 0.12.0.
Declared In:
lib/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public getBanners()
Return Value:
No value is returned.
Show Banner
This method shows a banner immediately.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Removed in: | 4.6.0 | 4.7.0 | 0.12.0 | - |
NOTE: This method was removed in SDK version 0.12.0.
Declared In:
lib/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public showBanner(banner: object, markPresented: boolean)
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| banner | object | yes | - | Object representation of a banner |
| markPresented | boolean | yes | - | Sets the banner as presented and this banner instance representation will not appear again |
Return Value:
No value is returned.
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/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public getWalkthrough()
Return Value:
No value is returned.
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/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public showWalkthrough()
Return Value:
No value is returned.
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/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public isWalkthroughLoaded(): boolean
Return Value:
true if the walkthrough is loaded, otherwise returns false.
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/main/modules/InjectorModule.js
Class:
InjectorModule
Declaration:
public isLoadedWalkthroughUnique(): boolean
Return Value:
true if the loaded walkthrough is unique, otherwise returns false.