Campaigns

Set Banner listener


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

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

Remove Banner listener


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

Method name:
Injector.removeBannerListener();

Declaration:

public static void removeBannerListener()

Parameters:
No parameters.

Return Value:
No value returned.

Example:

Injector.removeBannerListener();

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

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();

Register for push notifications


This method passes the Firebase Token to Synerise for notifications.

Note: The API key must have the API_BY_IDENTIFY_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, mobilePushAgreement)

Declaration:

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

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

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

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

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

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

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.

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

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

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

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

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

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

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());

Get Walkthrough


This method fetches a walkthrough.

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();

Show Walkthrough


This method shows a walkthrough when it is loaded.

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();

Check if Walkthrough is loaded


This method checks if a walkthrough is loaded.

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();

Check if is loaded Walkthrough unique


This method checks if the walkthrough is unique compared to the previous one.

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();

Get pushes


This method fetches Push Notifications set for mobile campaigns.

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

Removed 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 -

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();

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 -

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();

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

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker