Android

Android listeners

OnRegisterForPushListener

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.
This method returns true if activity is closed after executing an action; in other case, it returns false.

- boolean onOpenUrl(SyneriseSource source, String url)
fun onOpenUrl(source:SyneriseSource, url:String):Boolean
Parameter Type Description
source SyneriseSource Interaction source
url String URL value from the action of the activity

onOpenUrl(InjectorSource source, String url)

A listener to handle events from campaigns.

Fired when a customer interacts with the URL action.
This method returns true if activity is closed after executing an action; in other case, it returns false.

NOTE: This method was deprecated in SDK version 6.0.0.

- boolean onOpenUrl(InjectorSource source, String url)
fun onOpenUrl(source:InjectorSource, url:String):Boolean
Parameter Type Description
source InjectorSource Interaction source
url String URL value from the action of the activity

Fired when a customer interacts with the DEEP_LINKING action.
The method returns true if activity is closed after executing the action; in other case, it returns false.

- boolean onDeepLink(SyneriseSource source, String deepLink)
fun onDeepLink(source:SyneriseSource, deepLink:String):Boolean
Parameter Type Description
source SyneriseSource Interaction source
deepLink String Deep link value from the action of the activity

Fired when a customer interacts with the DEEP_LINKING action.
The method returns true if activity is closed after executing the action; in other case, it returns false.

NOTE: This method was deprecated in SDK version 6.0.0.

- boolean onDeepLink(InjectorSource source, String deepLink)
fun onDeepLink(source:InjectorSource, deepLink:String):Boolean
Parameter Type Description
source InjectorSource 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.

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)
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)
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)
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.

HashMap<String, Object> onContextFromAppRequired(InAppMessageData inAppMessageData)
onContextFromAppRequired(inAppMessageData: InAppMessageData): HashMap<String, Object>
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)
onHandledOpenUrl(inAppMessageData: InAppMessageData)
Parameter Type Description
inAppMessageData InAppMessageData In-app message data.

This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.

void onHandledOpenDeepLink(InAppMessageData inAppMessageData)
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)
onCustomAction(identifier: String, params: HashMap<String, Object> , 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.


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(InAppMessageData 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(InAppMessageData data)
onContextFromAppRequired(data: InAppMessageData): MutableMap<String, Any>
Parameter Type Description
data InAppMessageData 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.

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.

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

Canonical URL: https://hub.synerise.com/developers/mobile-sdk/listeners-and-delegates/android-listeners