React Native listeners
Initialization
A listener to handle the SDK lifecycle events.
Synerise.onReady(function() {
...
});
Synerise.onError(function(error) {
...
})
NotificationsListener
A listener to handle actions from the notifications module.
Synerise.Notifications.setListener({
// The following method is called when Synerise receives a registration token from the native part of application
// It is optional function
onRegistrationToken: function(token) {
...
},
// The following method is called when registration for Push Notifications is needed.
// It is optional function
onNotification: function(payload) {
...
},
// The following method is called when Synerise receives a notification's payload from the native part of application.
// It is optional function
onRegistrationRequired: function() {
...
}
});
NOTE: After invoking onRegistrationRequired() function, you must invoke the Synerise.Notifications.registerForNotifications(registrationToken, mobileAgreement, onSuccess, onError) method again.
ClientStateListener
A listener to handle customer's sign-in state changes.
Synerise.Client.setClientStateListener({
// The following method is called when a customer signs in.
// It is optional function
onClientSignedIn: function() {
...
},
// The following method is called when a customer signs out
// It is optional function
onClientSignedOut: function(reason) {
...
}
});
InjectorListener
A listener to handle URL and deeplink actions from the injector module.
Synerise.Injector.setListener({
// The following method is called when Synerise handles URL action from campaign activities
// It is required function
onOpenUrl: function(url) {
...
},
// The following method is called when Synerise handles deep link action from campaign activities
// It is required function
onDeepLink: function(deepLink) {
...
}
});
InjectorInAppMessageListener
A listener to handle the states of in-app messages.
Synerise.Injector.setInAppMessageListener({
// The following method is called after an in-app message appears
onPresent: function (data) {
...
},
// The following method is called after an in-app message disappears
onHide: function(data) {
...
},
// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
onOpenUrl: function (data, url) {
...
},
// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
onDeepLink: function (data, deepLink) {
...
},
// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an in-app message.
onCustomAction: function(data, name, parameters) {
}
})
To provide context for an in-app message, set Synerise.Injector.inAppContext[InAppContextKey.JinjavaContext] before the message is rendered. For details, see In-app context.
InjectorInlineInAppMessageListener
A listener to handle actions from inline in-app messages and to receive components created by the SDK for event-triggered campaigns. In code, the interface is IInlineInAppMessageListener
Synerise.Injector.setInlineInAppMessageListener({
// This method is called when the SDK creates a ready-to-display component
// after an event-based trigger for a placement with no mounted component.
onInlineInAppAvailable: (view, data) => {
...
},
// This method is called when the SRInApp.openUrl(url) method is used in an inline in-app message.
onOpenUrl: (data, url) => {
...
},
// This method is called when the SRInApp.openDeeplink(url) method is used in an inline in-app message.
onDeepLink: (data, deepLink) => {
...
},
// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an inline in-app message.
onCustomAction: (data, name, parameters) => {
...
},
// This method is called when the SRInApp.customMethod(name, params) method is used in an inline in-app message.
// Resolve the completion exactly once — with success or failure.
onCustomMethod: (data, name, parameters, completion) => {
completion.success({});
},
});
InjectorWalkthroughListener
NOTE: InjectorWalkthroughListener was removed in SDK version 1.0.0..
InjectorBannerListener
NOTE: InjectorBannerListener was removed in SDK version 1.0.0..