Android listeners
OnRegisterForPushListener
IMPORTANT: onRegisterForPushRequired() is abstract and must be implemented. onRegisterForPushRequired(PushRegistrationOrigin origin) is optional (available from SDK version 5.21.0, its default implementation does nothing). The SDK calls both methods for every registration request, so register the token in only one of them.
onRegisterForPushRequired(PushRegistrationOrigin origin)
This method is called when Synerise needs registration for push notifications.
See Configuring push notifications for more details.
- void onRegisterForPushRequired(PushRegistrationOrigin origin);
fun onRegisterForPushRequired(origin: PushRegistrationOrigin)
| Parameter | Type | Description |
|---|---|---|
| origin | PushRegistrationOrigin | Information about the cause of the registration |
onRegisterForPushRequired()
This method is called when Synerise needs registration for push notifications.
See Configuring push notifications for more details.
- void onRegisterForPushRequired();
fun onRegisterForPushRequired()
OnNotificationListener
A listener to handle events from Synerise notifications.
See Configuring push notifications for more details.
NOTE: OnNotificationListener is available from 4.9.0 SDK version.
onNotificationReceived(NotificationInfo notificationInfo)
This method is called when a Synerise notification is received.
- public void onNotificationReceived(NotificationInfo notificationInfo)
fun onNotificationReceived(notificationInfo: NotificationInfo)
| Parameter | Type | Description |
|---|---|---|
| notificationInfo | NotificationInfo | Object providing info about the notification. |
onNotificationDismissed(NotificationInfo notificationInfo)
This method is called when a Synerise notification is dismissed.
- public void onNotificationDismissed(NotificationInfo notificationInfo)
fun onNotificationDismissed(notificationInfo: NotificationInfo)
| Parameter | Type | Description |
|---|---|---|
| notificationInfo | NotificationInfo | Object providing info about the notification. |
onNotificationClicked(NotificationInfo notificationInfo)
This method is called when a Synerise notification is clicked.
- public void onNotificationClicked(NotificationInfo notificationInfo)
fun onNotificationClicked(notificationInfo: NotificationInfo)
| Parameter | Type | Description |
|---|---|---|
| notificationInfo | NotificationInfo | Object providing information about the notification. |
onActionButtonClicked(NotificationInfo notificationInfo, String actionButton)
This method is called when an action button is clicked in a Synerise notification.
- public void onActionButtonClicked(NotificationInfo notificationInfo, String actionButton)
fun onActionButtonClicked(notificationInfo: NotificationInfo, actionButton: String)
| Parameter | Type | Description |
|---|---|---|
| notificationInfo | NotificationInfo | Object providing information about the notification. |
| actionButton | String | Text on the clicked action button. |
OnClientStateChangeListener
A listener to handle customer's sign-in state changes.
To set your object with listener methods, you must use this method.
onClientSignedIn()
This method is called when the customer signs in.
- public void onClientSignedIn()
fun onClientSignedIn()
onClientSignedOut(ClientSessionEndReason reason)
This method is called when the customer signs out.
- public void onClientSignedOut(ClientSessionEndReason reason)
fun onClientSignedOut(reason:ClientSessionEndReason)
| Parameter | Type | Description |
|---|---|---|
| reason | ClientSessionEndReason | Specifies the reason for signing out. |
OnInjectorListener
onOpenUrl(SyneriseSource source, String url)
A listener to handle events from campaigns.
Fired when a customer interacts with the URL action.
The default implementation opens the URL using the system. When a listener is registered, the SDK never opens the URL itself.
- void onOpenUrl(SyneriseSource source, String url)
fun onOpenUrl(source:SyneriseSource, url:String)
| Parameter | Type | Description |
|---|---|---|
| source | SyneriseSource | Interaction source |
| url | String | URL value from the action of the activity |
onDeepLink(SyneriseSource source, String deepLink)
Fired when a customer interacts with the DEEP_LINKING action.
The default implementation opens the deep link using the system. When a listener is registered, the SDK never opens the deep link itself.
- void onDeepLink(SyneriseSource source, String deepLink)
fun onDeepLink(source:SyneriseSource, deepLink:String)
| Parameter | Type | Description |
|---|---|---|
| source | SyneriseSource | Interaction source |
| deepLink | String | Deep link value from the action of the activity |
OnInAppListener
A listener to handle the states of in-app message.
NOTE: OnInAppListener is available from 4.7.0 SDK version.
To set your object with listener methods, you must use this method.
OnInAppListener is an abstract class. Your subclass must implement all its methods except onCustomMethod, which is optional.
shouldShow(InAppMessageData inAppMessageData)
This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.
boolean shouldShow(InAppMessageData inAppMessageData)
override fun shouldShow(inAppMessageData: InAppMessageData): Boolean
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
onShown(InAppMessageData inAppMessageData)
This method is called after an in-app message appears.
void onShown(InAppMessageData inAppMessageData)
override fun onShown(inAppMessageData: InAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
onDismissed(InAppMessageData inAppMessageData)
This method is called after an in-app message disappears.
void onDismissed(InAppMessageData inAppMessageData)
override fun onDismissed(inAppMessageData: InAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
onContextFromAppRequired(InAppMessageData inAppMessageData)
This method is called when an individual context (for example a profile ID, an item SKU) for an in-app message is needed. This method is called on a background thread, so return quickly and don't access views.
HashMap<String, Object> onContextFromAppRequired(InAppMessageData inAppMessageData)
override fun onContextFromAppRequired(inAppMessageData: InAppMessageData): HashMap<String, Any>
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
onHandledOpenUrl(InAppMessageData inAppMessageData)
This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
void onHandledOpenUrl(InAppMessageData inAppMessageData)
override fun onHandledOpenUrl(inAppMessageData: InAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
onHandledOpenDeepLink(InAppMessageData inAppMessageData)
This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
void onHandledOpenDeepLink(InAppMessageData inAppMessageData)
override fun onHandledOpenDeepLink(inAppMessageData: InAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
onCustomAction(String identifier, HashMap<String, Object> params, InAppMessageData inAppMessageData)
This method is called when the SRInApp.handleCustomAction(name, params) method is used in an in-app message.
void onCustomAction(String identifier, HashMap<String, Object> params, InAppMessageData inAppMessageData)
override fun onCustomAction(identifier: String, params: HashMap<String, Any>, inAppMessageData: InAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| inAppMessageData | InAppMessageData | In-app message data. |
| identifier | String | Identifier of the custom action. |
| params | HashMap<String, Object> | Custom action parameters. |
onCustomMethod(String name, HashMap<String, Object> params, InAppMessageData inAppMessageData, InAppCustomMethodCompletion completion)
This method is called when the SRInApp.customMethod(name, params) method is used in an in-app message. Resolve the completion exactly once with success or failure.
This method is optional. If you don't override it, the default implementation fails the completion with onCustomMethod not implemented
NOTE: This method is available from 6.14.0 SDK version.
void onCustomMethod(String name, HashMap<String, Object> params, InAppMessageData inAppMessageData, InAppCustomMethodCompletion completion)
override fun onCustomMethod(name: String, params: HashMap<String, Any>, inAppMessageData: InAppMessageData, completion: InAppCustomMethodCompletion)
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the custom method. |
| params | HashMap<String, Object> | Custom method parameters. |
| inAppMessageData | InAppMessageData | In-app message data. |
| completion | InAppCustomMethodCompletion | Completion to resolve with success() or failure() |
OnInlineInAppListener
A listener to handle global events for inline in-app messages.
To set your object with listener methods, you must use this method.
onInlineInAppAvailable(InlineInAppView view, InlineInAppMessageData data)
This method is called when the SDK creates a ready-to-display component after an event-based trigger for a placement with no existing host view.
void onInlineInAppAvailable(InlineInAppView view, InlineInAppMessageData data)
onInlineInAppAvailable(view: InlineInAppView, data: InlineInAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| view | InlineInAppView | The ready-to-display inline in-app view. |
| data | InlineInAppMessageData | Inline in-app message data. |
onContextFromAppRequired(InlineInAppMessageData data)
This method is called when a per-message context is needed for rendering. This method is called on a background thread.
Map<String, Object> onContextFromAppRequired(InlineInAppMessageData data)
onContextFromAppRequired(data: InlineInAppMessageData): MutableMap<String, Any>
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
onOpenedUrl(InlineInAppMessageData data, String url)
This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
void onOpenedUrl(InlineInAppMessageData data, String url)
onOpenedUrl(data: InlineInAppMessageData, url: String)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
| url | String | The URL to open. |
onOpenedDeepLink(InlineInAppMessageData data, String deepLink)
This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
void onOpenedDeepLink(InlineInAppMessageData data, String deepLink)
onOpenedDeepLink(data: InlineInAppMessageData, deepLink: String)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
| deepLink | String | The deep link value. |
onCustomAction(InlineInAppMessageData data, String name, Map<String, Object> params)
This method is called when the SRInApp.handleCustomAction(name, params) method is used in an in-app message.
void onCustomAction(InlineInAppMessageData data, String name, Map<String, Object> params)
onCustomAction(data: InlineInAppMessageData, name: String, params: Map<String, Any>)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
| name | String | Name of the custom action. |
| params | Map<String, Object> | Custom action parameters. |
onCustomMethod(String name, HashMap<String, Object> params, InlineInAppMessageData data, InAppCustomMethodCompletion completion)
This method is called when the SRInApp.customMethod(name, params) method is used in an in-app message. Resolve the completion exactly once with success or failure.
void onCustomMethod(String name, HashMap<String, Object> params, InlineInAppMessageData data, InAppCustomMethodCompletion completion)
onCustomMethod(name: String, params: HashMap<String, Any>, data: InlineInAppMessageData, completion: InAppCustomMethodCompletion)
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the custom method. |
| params | HashMap<String, Object> | Custom method parameters. |
| data | InlineInAppMessageData | Inline in-app message data. |
| completion | InAppCustomMethodCompletion | Completion to resolve with success() or failure(). |
OnInlineInAppViewListener
A per-component listener to handle the lifecycle of an inline in-app message view.
onProcessingStarted()
This method is called when the SDK starts processing a campaign for this component.
void onProcessingStarted()
onProcessingStarted()
onLoaded(InlineInAppMessageData data)
This method is called when the inline in-app message content is loaded for the first time.
void onLoaded(InlineInAppMessageData data)
onLoaded(data: InlineInAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
onUpdated(InlineInAppMessageData data)
This method is called when the inline in-app message content is updated with a new campaign.
void onUpdated(InlineInAppMessageData data)
onUpdated(data: InlineInAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
onFailed(InlineInAppMessageData data, String error)
This method is called when the inline in-app message content fails to load or render.
void onFailed(InlineInAppMessageData data, String error)
onFailed(data: InlineInAppMessageData, error: String)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
| error | String | Error description. |
onSizeChanged(InlineInAppMessageData data, InlineInAppSize size)
This method is called when the in-app message content requests a size change via the SRInApp.setComponentSize(width, height) JS method. The measured size is delivered as an InlineInAppSize, exposing it in physical pixels, density-independent pixels (dp), and as a fraction of the device screen.
void onSizeChanged(InlineInAppMessageData data, InlineInAppSize size)
onSizeChanged(data: InlineInAppMessageData, size: InlineInAppSize)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
| size | InlineInAppSize | The requested size. Exposes getWidthPx()/getHeightPx() (physical pixels), getWidthDp()/getHeightDp() (density-independent pixels), and getWidthScreenRatio()/getHeightScreenRatio() (0..1 fraction of the screen). |
onRemove(InlineInAppMessageData data)
This method is called when the in-app message content requests removal from the view hierarchy via the SRInApp.close() or SRInApp.closeAndTrigger() JS method, or when the application calls Injector.closeInAppMessage(campaignHash)
void onRemove(InlineInAppMessageData data)
onRemove(data: InlineInAppMessageData)
| Parameter | Type | Description |
|---|---|---|
| data | InlineInAppMessageData | Inline in-app message data. |
OnLocationUpdateListener
A listener to handle events about location.
onLocationUpdateRequired()
This method is called when the Tracker module requests a location update.
- void onLocationUpdateRequired()
fun onLocationUpdateRequired()
OnContentWidgetListener
A listener to handle Content Widget actions.
onLoad(ContentWidget contentWidget)
This method is called after a widget is loaded.
- void onLoad(ContentWidget contentWidget)
fun onLoad(contentWidget:ContentWidget)
| Parameter | Type | Description |
|---|---|---|
| **contentWidget` | ContentWidget | The widget instance that called the listener method |
onLoadingError(ContentWidget contentWidget, ApiError apiError)
This method is called when an error occurs while loading a widget.
- void onLoadingError(ContentWidget contentWidget, ApiError apiError)
fun onLoadingError(contentWidget:ContentWidget, apiError:ApiError)
| Parameter | Type | Description |
|---|---|---|
| contentWidget | ContentWidget | The widget instance that called the listener method |
| apiError | ApiError | The error that occurred |
onClickActionReceive(ContentWidget contentWidget, BaseModel model)
This method is called when the customer clicks a widget’s item.
- void onClickActionReceive(ContentWidget contentWidget, BaseModel model)
fun onClickActionReceive(contentWidget:ContentWidget, model:BaseModel)
| Parameter | Type | Description |
|---|---|---|
| contentWidget | ContentWidget | The widget instance that called the listener method |
| model | BaseModel | The model's object that was clicked |
onLoading(ContentWidget contentWidget, boolean isLoading)
This method is called when the widget’s loading state changes.
- void onLoading(ContentWidget contentWidget, boolean isLoading)
fun onLoading(contentWidget:ContentWidget, isLoading:Boolean)
| Parameter | Type | Description |
|---|---|---|
| contentWidget | ContentWidget | The widget instance that called the listener method |
| isLoading | Boolean | Widget's loading state |
onSizeChange(ContentWidget contentWidget, ViewGroup.LayoutParams size)
This method is called when the widget’s size changes.
- void onSizeChange(ContentWidget contentWidget, ViewGroup.LayoutParams size)
fun onSizeChange(contentWidget:ContentWidget, size:ViewGroup.LayoutParams)
| Parameter | Type | Description |
|---|---|---|
| contentWidget | ContentWidget | The widget instance that called the listener method |
| size | ViewGroup.LayoutParams | Widget's new size |