Campaigns

Simple Push

Simple push is served by simple push notifications.

Note: Simple Push Campaigns are served by Push Notifications. To configure Push Notifications, see this article.

If an app was not active (was closed or running in the background) and a campaign is received, a push notification appears in the notification center. When a customer clicks the notification, they are taken to the application and a simple push is presented.

If an app is active, the simple push is presented right away.

Payload

If you want to handle notifications with your own methods, remember to change the issuer field. If issuer is set to “Synerise”, the payload is always handled by the Synerise SDK.

{
  "data": {
    "issuer": "Synerise",
    "message-type": "static-content",
    "content-type": "simple-push",
    "content": {
      "notification": {
        "title": "Synerise Simple Push title",
        "body": "Synerise Simple Push message",
        "sound": "default",
        "icon": "_your_https_url/marvellous_image.jpg",
        "priority": "HIGH",
        "action": {
          "item": "_your_link/",
          "type": "OPEN_URL"
        }
      },
      "buttons": [
        {
          "identifier": "button_1",
          "action": {
            "item": "_your_link/",
            "type": "OPEN_URL"
          },
          "text": "Button 1"
        },
        {
          "identifier": "button_2",
          "action": {
            "item": "syne://product?sku=el-oven",
            "type": "DEEP_LINKING"
          },
          "text": "Button 2"
        }
      ],
      "campaign": {
        "variant_id": 12345,
        "type": "Mobile push",
        "title": "Mobile push test campaign",
        "hash_id": "1893b5be-79c6-4432-xxxx-81e7bd4ea09d"
      }
    }
  }
}

Available action types:

  • DEEP_LINKING
  • OPEN_URL
  • OPEN_APP

Available priority types:

  • NORMAL
  • HIGH

Banners are served by silent push notifications.

Note: Before you can start using this feature, you must configure push notifications. Click here for details.

Banners are presented only when your app is in the foreground. When the app is in the background or destroyed, a simple push appears instead.
It is not always suitable for you to display every incoming banner. The application may be in a state where you don’t want to interrupt the customer.

You can control incoming banners by implementing the listener OnBannerListener:

  • Callback shouldPresent decides whether to show the incoming banner. By default, the SDK enables banner display.
  • Callback onPresented is fired when the banner is successfully created and presented to the customer.
    If the banner’s content is invalid, the banner is not presented and the callback is not fired.
  • Callback onClosed is fired when the banner is closed.
public static OnBannerListener NULL = new OnBannerListener() {
        @Override
        public boolean shouldPresent(TemplateBanner banner) {
            return true;
        }

        @Override
        public void onPresented() { }

        @Override
        public void onClosed() { }
    };

Payload

Banners can have the following layouts:

  • color_as_background
  • image_as_background
  • image_with_text_atop
  • image_with_text_below
{
  "notification": {
    "title": "Notification title if app was invisible",
    "body": "Notification message if app was invisible"
  },
  "data": {
    "issuer": "Synerise",
    "message-type": "dynamic-content",
    "content-type": "template-banner",
    "content": {
      "page": {
        "type": "image_with_text_atop",
        "button": {
          "is_enabled": true,
          "corner_radius": 40,
          "color": "#13e413",
          "text": "Navigate to Synerise",
          "text_color": "#1f74d9"
        },
        "image": {
          "url": "_your_https_url/marvellous_image.jpg"
        },
        "close_button": {
          "is_enabled": true,
          "alignment": "LEFT"
        },
        "background": {
          "color": "#d319d3",
          "alpha": 0.5
        },
        "index": 0,
        "header": {
          "color": "#384350",
          "size": 35,
          "alpha": 1,
          "text": "SYNERISE"
        },
        "description": {
          "color": "#384350",
          "size": 20,
          "alpha": 1,
          "text": "Click below button to open Synerise website"
        },
        "action": {
          "item": "_your_link_",
          "type": "OPEN_URL"
        }
      },
      "auto_disappear": {
        "is_enabled": true,
        "timeout": 5
      },
      "campaign": {
        "variant_id": 12345,
        "type": "Mobile banner",
        "title": "Mobile banner test campaign",
        "hash_id": "1893b5be-79c6-4432-xxxx-81e7bd4ea09d"
      }
    }
  }
}
Important:

When the app is not running, the banner appears as a notification with the default Firebase notification icon (your application’s icon).
If you want to set another icon, modify the Android manifest file:

<meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/your_icon_here" />

Triggers

In order to show a banner immediately after a certain event occurred, you can send your banners from the Synerise panel with a trigger value.

When Injector.fetchBanners(success:failure:) is called, it fetches all available banners, and then SDK caches those that are valid. You receive an array of banners formatted as a dictionary.

This method is also called during SDK initialization, so use it only when you wish to overwrite the current banners in SDK cache.

Injector.getBanners() provides valid banners directly from the SDK cache.

Note: The exact same banners are being searched for eventual campaign triggers.

You can keep banner data from:

  • Injector.fetchBanners(success:failure:) - fetch available banners (SDK will refresh cache).
  • Injector.getBanners() - get available banners from SDK cache.
  • snr_shouldBannerAppear(bannerDictionary: Dictionary) - optional delegate method. See Banner campaign section above for more information.

Next, call Injector.showBanner(_: Dictionary) to show a banner immediately. In this case, the delegate method snr_shouldBannerAppear(bannerDictionary: Dictionary) will not be called.

Note: The banner will appear even if your View Controller implements SyneriseActivityNotAllowed protocol. See common features for more information.

Walkthrough

Synerise SDK provides multiple functionalities within Walkthrough implementation.

You can specify Walkthrough behavior when the SDK initializes:

Synerise.Builder.with(this, syneriseClientApiKey, appId)
        .notificationIcon(R.drawable.ic_notification_icon)
        .injectorAutomatic(true)
        .build();

Setting .injectorAutomatic(true) will fetch the Walkthrough right away. That Walkthrough will be presented the moment it gets loaded, atop of your current Activity, if the ID of the walkthrough is different than previously presented.

Note that the walkthrough is a translucent activity, so your activity’s onStop() method may not be called. Also, the walkthrough activity is launched with the FLAG_ACTIVITY_NEW_TASK flag, so you can handle your activity stack properly. To control this behavior, fetch your Walkthrough manually with Injector.getWalkthrough().

This method cancels the previous API request (if any) and then starts loading Walkthrough asynchronously. It must be called after Injector.setOnWalkthroughListener(OnWalkthroughListener) to receive callbacks properly. See the Optional callbacks section.

You can check if Walkthrough is already loaded with the Injector.isWalkthroughLoaded() method, which returns true if the Walkthrough is already loaded.

There is also an enhanced method to check if Walkthrough is loaded: Injector.isLoadedWalkthroughUnique() verifies whether the loaded Walkthrough is different than previously presented. Every time any Walkthrough is presented, its ID is cached locally, so you can control your flow more precisely.
The method returns true if the loaded Walkthrough is different than previously presented, false otherwise or if a Walkthrough is not loaded.

Injector.showWalkthrough() shows the Walkthrough if loaded. This method may be called anywhere in your application as many times as you want. It also returns true if the Walkthrough was loaded, false otherwise.

Optional callbacks

When you choose to load and present a Walkthrough manually, you may use the following callbacks:

Injector.setOnWalkthroughListener(new OnWalkthroughListener() {
            @Override
            public void onLoadingError(ApiError error) {
                error.printStackTrace();
                goDashboard();
            }
            @Override
            public void onLoaded() {
                if (Injector.isLoadedWalkthroughUnique()) {
                    Injector.showWalkthrough();
                } else {
                    goDashboard();
                }
            }
            @Override
            public void onPresented() {
                super.onPresented();
            }
            @Override
            public void onClosed() {
                super.onClosed();
            }
        });

Note that all these methods are optional and overriding them is not required. These are also called when a Walkthrough was loaded automatically.

  • onLoadingError(ApiError) - This callback is fired the moment after a Walkthrough failed to get initialized. This error may be caused by unsuccessful API response or invalid Walkthrough content.
    An ApiError instance is provided to check the cause of the error.
  • onLoaded() - This callback is fired the moment after a Walkthrough is initialized successfully. Remember that the Walkthrough will be shown automatically if Synerise.Builder.injectorAutomatic(boolean) was set to true and if the ID of the Walkthrough is different than previously presented.
  • onPresented() - This callback is fired when a Walkthrough is successfully created and will be presented to the customer. Note that Walkthrough will not be presented to customer if its content is invalid, and therefore callback will not be fired.
  • onClosed() - This callback is fired when a Walkthrough is closed (just before actually closing).

Remember to remove the Walkthrough listener to stop receiving callbacks:

Injector.removeWalkthroughListener();

Common features

Handling app invisibility

If an app was invisible to a customer (minimized or destroyed) and a campaign banner is received - the simple push message is presented to the customer and launcher activity is fired after the notification is clicked.
This is the best moment to pass this data and the SDK verifies if it is a campaign banner.
If it is, the banner is presented within the app (atop of your activities). Please note that banner is a translucent activity, so your activity’s onStop() method may not be called.
Banner activity is launched with the FLAG_ACTIVITY_NEW_TASK flag, so you can handle your activity stack properly.
If your launcher activity lasts quite longer, check the onNewIntent(Intent) implementation below.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        boolean isSynerisePush = Injector.handlePushPayload(getIntent().getExtras());
    }
Note: The Injector.handlePushPayload(getIntent().getExtras()); method must be called to handle notifications by SyneriseSDK.

When your launcher activity takes more time, you might be interested in the onNewIntent(Intent) method.
In this case, it is preferred to override this method.
This is because when a campaign banner is received while the app is minimized, a simple push is presented to the customer in the system tray.
If your launcher activity was already created and the notification was clicked, your onCreate(Bundle) method will not be called.

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        boolean isSynerisePush = Injector.handlePushPayload(intent.getExtras());
    }

Own implementation (Simple Push, Banner)

You can also react to Synerise push notifications in your own way, using the payloads presented earlier in this article.

You may need to know whether an incoming push message comes from Synerise nad what data is included.

  • Injector.isSynerisePush(Map<String, String>) only checks whether the provided push data comes from Synerise.
    It is validated by checking if the incoming push contains the “issuer” key with the “Synerise” value.
  • Injector.isSyneriseSimplePush(Map<String, String>) only checks whether the provided push data comes from Synerise and if it is specifically a Synerise Simple Push.
    It is validated by checking if the incoming push contains the “content-type” key with the “simple-push” value.
  • Injector.isSyneriseBanner(Map<String, String>) only checks whether the provided push data comes from Synerise and if it is specifically a Synerise Banner.
    It is validated by checking if the incoming push contains the “content-type” key with the “template-banner” value.
  • Injector.isSilentCommand only checks whether the provided push data comes from Synerise and if it is specifically a Silent Command.
    It is validated by checking if the incoming push contains the “content-type” key with the “silent-command” value.
  • Injector.isSilentSdkCommand only checks whether the provided push data comes from Synerise and if it is specifically a Silent SDK Command.
    It is validated by checking if the incoming push contains the “content-type” key with the “silent-sdk-command” value.

Campaign Pushes information

Injector.getPushes() gets all available simple and silent pushes for a customer.

IDataApiCall with parameterized list of SynerisePushResponse is returned to execute request.

😕

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.