Campaigns

Set In-App listener


Sets inAppListener to injector. Method name:
Injector.setOnInAppListener(OnInAppListener listener)

Declaration:

public static void setOnInAppListener(OnInAppListener listener)

Parameters:

Parameter Type Mandatory Default Description
listener OnInAppListener yes - Listener

Return Value:
No value returned.

Example:

Injector.setOnInAppListener(listener);
Injector.setOnInAppListener(listener)

Remove In-App listener


Removes inAppListener from injector. Method name:
Injector.removeInAppListener()

Declaration:

public static void removeInAppListener()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

Injector.removeInAppListener();
Injector.removeInAppListener()

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
Method name:
Injector.closeInAppMessage(campaignHash)

Declaration:

public static void closeInAppMessage(String campaignHash)

Parameters:

Parameter Type Mandatory Default Description
campaignHash string yes - Unique identifier of the in-app campaign

Return value:
No value returned.

Example:

Injector.closeInAppMessage(campaignHash);
Injector.closeInAppMessage(campaignHash)

Set Inline In-App listener


Sets the global listener for inline in-app message events. Method name:
Injector.setOnInlineInAppListener(OnInlineInAppListener listener)

Declaration:

public static void setOnInlineInAppListener(OnInlineInAppListener listener)

Parameters:

Parameter Type Mandatory Default Description
listener OnInlineInAppListener yes - Listener for inline in-app message events

Return Value:
No value returned.

Example:

Injector.setOnInlineInAppListener(listener);
Injector.setOnInlineInAppListener(listener)

Remove Inline In-App listener


Removes the global inline in-app message listener from injector. Method name:
Injector.removeInlineInAppListener()

Declaration:

public static void removeInlineInAppListener()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

Injector.removeInlineInAppListener();
Injector.removeInlineInAppListener()

Create Inline In-App view


Creates an inline in-app message view for a given placement key. The returned view must be embedded into the app's view hierarchy by the application. Method name:
Injector.createInlineInAppView(Context context, String placementKey)

Declaration:

public static InlineInAppView createInlineInAppView(Context context, String placementKey)

Parameters:

Parameter Type Mandatory Default Description
context Context yes - Android context
placementKey String yes - Identifier of the placement configured in the Synerise platform

Return Value:
InlineInAppView object.

Example:

InlineInAppView inlineView = Injector.createInlineInAppView(context, "home_top_banner");
val inlineView = Injector.createInlineInAppView(context, "home_top_banner")

Notify In-App context change


Notifies all active in-app message components that the global context has changed. After this call, the SDK invokes SRInApp.onContextFromApp(context) in each active in-app message. Method name:
Injector.notifyInAppContextChange()

Declaration:

public static void notifyInAppContextChange()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

Injector.inAppContext = context;
Injector.notifyInAppContextChange();
Injector.inAppContext = context
Injector.notifyInAppContextChange()

Get Inline In-App view identifier


Returns the free-form identifier attached to this view by the application. Not used by the SDK. Method name:
InlineInAppView.getIdentifier()

Declaration:

public String getIdentifier()

Parameters:
No parameters.

Return Value:
String identifier or null.

Example:

String identifier = inlineView.getIdentifier();
val identifier = inlineView.getIdentifier()

Set Inline In-App view identifier


Sets a free-form identifier on the view. The identifier is not used by the SDK — it exists so the application can tell multiple InlineInAppView instances apart. Method name:
InlineInAppView.setIdentifier(String)

Declaration:

public void setIdentifier(String identifier)

Parameters:

Parameter Type Description
identifier String A free-form identifier for this view

Return Value:
No value returned.

Example:

inlineView.setIdentifier("home_top");
inlineView.setIdentifier("home_top")

Check if Inline In-App view is rendered


Returns whether an inline in-app message campaign is currently rendered in this view. Method name:
InlineInAppView.isRendered()

Declaration:

public boolean isRendered()

Parameters:
No parameters.

Return Value:
true if a campaign is currently rendered in this view, false otherwise.

Example:

boolean rendered = inlineView.isRendered();
val rendered = inlineView.isRendered()

Get Inline In-App view placement key


Returns the placement key this view is bound to. Method name:
InlineInAppView.getPlacementKey()

Declaration:

public String getPlacementKey()

Parameters:
No parameters.

Return Value:
String — the placement key this view is bound to, or null if none was set.

Example:

String placementKey = inlineView.getPlacementKey();
val placementKey = inlineView.getPlacementKey()

Render Inline In-App view


Triggers on-demand rendering of content in an inline in-app view. Use this method when the campaign trigger type is set to "on demand". Method name:
InlineInAppView.render()

Declaration:

public void render()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

inlineView.render();
inlineView.render()

Get Inline In-App view data


Returns the data of the currently loaded inline in-app message campaign. Method name:
InlineInAppView.getData()

Declaration:

public InlineInAppMessageData getData()

Parameters:
No parameters.

Return Value:
InlineInAppMessageData object or null.

Example:

InlineInAppMessageData data = inlineView.getData();
val data = inlineView.getData()

Release Inline In-App view


Releases the resources held by the inline in-app view, including the WebView and campaign state, and unregisters the component from the SDK. Call this method before removing the view from the hierarchy. Method name:
InlineInAppView.release()

Declaration:

public void release()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

inlineView.release();
ViewGroup parent = (ViewGroup) inlineView.getParent();
if (parent != null) {
    parent.removeView(inlineView);
}
inlineView = null;
inlineView?.release()
(inlineView?.parent as? ViewGroup)?.removeView(inlineView)
inlineView = null

Register for push notifications


This method passes the Firebase Token to Synerise for notifications.

NOTE:
  • 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_UPDATE permission 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).

Method name:
Client.registerForPush(firebaseId, mobilePushAgreement)

Declaration:

public static IApiCall registerForPush(@NonNull String firebaseId, boolean mobilePushAgreement)
fun registerForPush(@NonNull firebaseId:String, mobilePushAgreement:boolean):IApiCall

NOTE: This method has a built-in cache mechanism. If you try to post the same data within 24 hours, the call to the backend isn't made.

Parameters:

Parameter Type Mandatory Default Description
firebaseId String yes - FirebaseInstanceId
mobilePushAgreement boolean yes - Agreement (consent) for mobile push campaigns

Return Value:
IApiCall object to execute the request.

Example:

IApiCall call = Client.registerForPush(refreshedToken, true);
            call.execute(() -> Log.d(TAG, "Register for Push succeed: " + refreshedToken),
                         apiError -> Log.w(TAG, "Register for push failed: " + refreshedToken));
val call = Client.registerForPush(refreshedToken, true)
call.execute({ Log.d(TAG, "Register for Push succeed: " + refreshedToken) },
             { apiError-> Log.w(TAG, "Register for push failed: " + refreshedToken) })

Register for push notifications without agreement


This method passes the Firebase Token to Synerise for notifications and doesn't update the agreement of the profile.

iOS SDK Android SDK React Native SDK Flutter SDK
Introduced in: 4.14.0 5.7.1 0.15.0 1.1.0

NOTE: The API key must have the API_PERSONAL_DEVICE_CLIENT_UPDATE permission from the Client group.

NOTE: If the registration fails, the SDK requests a token update again by a listener/delegate method (Android, iOS, React Native, Flutter).

Method name:
Client.registerForPush(firebaseId)

Declaration:

public static IApiCall registerForPush(@NonNull String firebaseId)
fun registerForPush(@NonNull firebaseId:String):IApiCall

NOTE: This method has a built-in cache mechanism. If you try to post the same data within 24 hours, the call to the backend isn't made.

Parameters:

Parameter Type Mandatory Default Description
firebaseId String yes - FirebaseInstanceId

Return Value:
IApiCall object to execute the request.

Example:

IApiCall call = Client.registerForPush(refreshedToken);
            call.execute(() -> Log.d(TAG, "Register for Push succeed: " + refreshedToken),
                         apiError -> Log.w(TAG, "Register for push failed: " + refreshedToken));
val call = Client.registerForPush(refreshedToken)
call.execute({ Log.d(TAG, "Register for Push succeed: " + refreshedToken) },
             { apiError-> Log.w(TAG, "Register for push failed: " + refreshedToken) })

Check if push notification is from Synerise


This method verifies if a notification was sent by Synerise. Method name:
Injector.isSynerisePush(pushPayload);

Declaration:

public static boolean isSynerisePush(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data. The "issuer" key must be set to "Synerise".

Return Value:
Boolean indicating if the incoming push contains an "issuer" key with the "Synerise" value.

Example:

boolean isSynerisePush = Injector.isSynerisePush(data);
var isSynerisePush = Injector.isSynerisePush(data)

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 Method name:
Injector.isSyneriseSimplePush(pushPayload);

Declaration:

public static boolean isSyneriseSimplePush(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data. The "issuer" key must be set to "Synerise".

Return Value:
Boolean indicating if the incoming push contains a "content-type" key with the "simple-push" value.

Example:

boolean isSyneriseSimplePush = Injector.isSyneriseSimplePush(data);
var isSyneriseSimplePush = Injector.isSyneriseSimplePush(data)

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. Method name:
Injector.isSilentCommand(pushPayload);

Declaration:

public static boolean isSilentCommand(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data. The "issuer" key must be set to "Synerise".

Return Value:
Boolean indicating if the incoming push contains a "content-type" key with the "silent-command" value.

Example:

boolean isSilentCommand = Injector.isSilentCommand(data);
var isSilentCommand = Injector.isSilentCommand(data)

Get a Silent Command


Method that converts push payload into a SilentCommand object. Method name:
Injector.getSilentCommand(payload);

Declaration:

public static SilentCommand getSilentCommand(Map<String, String> payload) throws ValidationException

Parameters:

Parameter Type Mandatory Default Description
payload Map<String, String> yes - payload received from push

Return Value:
SilentCommand object, may be null if the payload is not a SilentCommand payload.

Example:

SilentCommand silentCommand = Injector.getSilentCommand(payload);
var silentCommand = Injector.getSilentCommand(payload)

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. Method name:
Injector.isSilentCommandSdk(pushPayload);

Declaration:

public static boolean isSilentCommandSdk(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data. The "issuer" key must be set to "Synerise".

Return Value:
Boolean indicating if the incoming push contains a "content-type" key with the "silent-sdk-command" value.

Example:

boolean isSilentCommandSdk = Injector.isSilentCommandSdk(data);
var isSilentCommandSdk = Injector.isSilentCommandSdk(data)

Check if push notification is encrypted


This method verifies if a notification is encrypted. Method name:
Injector.isPushEncrypted(pushPayload);

Declaration:

public static boolean isPushEncrypted(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data

Return Value:
Boolean indicating if the incoming push is encrypted by Synerise.

Example:

boolean isPushEncrypted = Injector.isPushEncrypted(data);
var isPushEncrypted = Injector.isPushEncrypted(data)

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.

Method name:
Injector.decryptPushPayload(pushPayload);

Declaration:

public static Map<String, String> decryptPushPayload(Map<String, String> pushPayload) throws DecryptionException

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data

Return Value:
Key-Value map of data with the decrypted push.

Example:

Injector.decryptPushPayload(data);
Injector.decryptPushPayload(data)

Handle Synerise push notification


This method handles a notification payload and starts activity.

NOTE: It is recommended to call this method from your FirebaseMessagingService subclass within the onMessageReceived(RemoteMessage) method.

Method name:
Injector.handlePushPayload(pushPayload);

Declaration:

public static boolean handlePushPayload(Bundle bundle)
public static boolean handlePushPayload(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
bundle Bundle yes - Bundle of data. Key "issuer" must be set to "Synerise".
pushPayload Map<String, String> yes - Key-Value map of data. The "issuer" key must be set to "Synerise".

Return Value:
Boolean indicating if the incoming push contains an "issuer" key with the value "Synerise".

Example:

boolean isSynerisePush = Injector.handlePushPayload(getIntent().getExtras());
var isSynerisePush = Injector.handlePushPayload(getIntent().getExtras())

Get pushes


This method fetches Push Notifications set for mobile campaigns.

iOS SDK Android SDK React Native SDK Flutter SDK
Removed in: 5.0.0 6.0.0 n/a n/a

NOTE: The API key must have the CAMPAIGN_BACKEND_COLLECTOR_READ permission from the Collector group.

Method name:
Injector.getPushes();

Declaration:

public static IDataApiCall<List<SynerisePushResponse>> getPushes()

Parameters:
No parameters.

Return Value:
IDataApiCall<List<SynerisePushResponse>> with a parameterized list of SynerisePushResponse to execute a request.

Example:

IDataApiCall<List<SynerisePushResponse>> apiCall = Injector.getPushes();
        apiCall.execute(this::success, this::showAlertError);
val apiCall = Injector.getPushes()
apiCall.execute(({ this.success() }), ({ this.showAlertError() }))

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 n/a
Method name:
Injector.isSyneriseBanner(pushPayload);

Declaration:

public static boolean isSyneriseBanner(Map<String, String> pushPayload)

Parameters:

Parameter Type Mandatory Default Description
pushPayload Map<String, String> yes - Key-Value map of data. The "issuer" key must be set to "Synerise".

Return Value:
Boolean indicating if the incoming push contains a "content-type" key with the "template-banner" value.

Example:

boolean isSyneriseBanner = Injector.isSyneriseBanner(data);
var isSyneriseBanner = Injector.isSyneriseBanner(data)

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
Method name:
Injector.fetchBanners(successListener, errorListener);

Declaration:

public static void fetchBanners()
public static void fetchBanners(@NonNull final DataActionListener<List<TemplateBanner>> successListener,
                                    @NonNull final DataActionListener<ApiError> errorListener)

Parameters:

Parameter Type Mandatory Default Description
successListener DataActionListener<List<TemplateBanner>> yes - Success data callback with valid banners.
errorListener DataActionListener<ApiError> yes - Error callback with an ApiError instance.

Return Value:
No value is returned.

Example:

Injector.fetchBanners();
Injector.fetchBanners();

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
Method name:
Injector.getBanners();

Declaration:

public static List<TemplateBanner> getBanners()

Parameters:
No parameters.

Return Value:
List<TemplateBanner> of cached banners.

Example:

List<TemplateBanner> bannerList = Injector.getBanners();
var bannerList = Injector.getBanners()

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 -
Method name:
Injector.showBanner(banner, markPresented);

Declaration:

public static void showBanner(TemplateBanner banner, boolean markPresented)

Parameters:

Parameter Type Mandatory Default Description
banner TemplateBanner yes - Banner to display
markPresented boolean yes - Flag indicating if the banner should be marked as presented and not be presented the next time

Return Value:
No value returned.

Example:

Injector.showBanner(banner, markPresented);
Injector.showBanner(banner, markPresented)

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.

NOTE: To receive callbacks properly, this method should be called after Injector.setOnWalkthroughListener(OnWalkthroughListener).

Method name:
Injector.getWalkthrough();

Declaration:

public static void getWalkthrough()

Parameters:
No parameters.

Return Value:
No return value.

Example:

Injector.getWalkthrough();
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
Method name:
Injector.showWalkthrough();

Declaration:

public static boolean showWalkthrough()

Parameters:
No parameters.

Return Value:
Boolean value is returned. true if the loaded or cached Walkthrough was presented, false otherwise.

Example:

Injector.showWalkthrough();
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
Method name:
Injector.isWalkthroughLoaded();

Declaration:

public static boolean isWalkthroughLoaded()

Parameters:
No parameters.

Return Value:
Boolean value is returned. true if Walkthrough is already loaded, false otherwise.

Example:

Boolean isWalkthroughLoaded = Injector.isWalkthroughLoaded();
var isWalkthroughLoaded = Injector.isWalkthroughLoaded()

Check if loaded Walkthrough is 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
Method name:
Injector.isLoadedWalkthroughUnique();

Declaration:

public static boolean isLoadedWalkthroughUnique()

Parameters:
No parameters.

Return Value:
Returns true if the loaded Walkthrough is loaded and different than previously presented, false otherwise.

Example:

Boolean isWalkthroughLoadedUnique = Injector.isLoadedWalkthroughUnique();
var isWalkthroughLoadedUnique = Injector.isLoadedWalkthroughUnique()

Set Banner listener


Set your own banner listener to receive optional callbacks.
Instantiate OnBannerListener and override the desired callbacks.

iOS SDK Android SDK React Native SDK Flutter SDK
Removed in: n/a 6.0.0 n/a n/a

Method name:
Injector.setOnBannerListener(banner, markPresented);

Declaration:

public static void setOnBannerListener(OnBannerListener listener)

Parameters:

Parameter Type Mandatory Default Description
listener OnBannerListener yes - Listener

Return Value:
No value returned.

Example:

Injector.setOnBannerListener(listener);
Injector.setOnBannerListener(listener)

Remove Banner listener


Remove banner listener to stop receiving callbacks.
It is recommended to call this method when your Activity is stopped.

iOS SDK Android SDK React Native SDK Flutter SDK
Removed in: n/a 6.0.0 n/a n/a

Method name:
Injector.removeBannerListener();

Declaration:

public static void removeBannerListener()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

Injector.removeBannerListener();
Injector.removeBannerListener()

Canonical URL: https://hub.synerise.com/developers/mobile-sdk/method-reference/android/campaigns