Push Display Handled by Application


This section is only required for very advanced use-cases where the application needs to handle the push display on their side. We believe that customization provided in Advanced Push Configuration should solve most of your use-cases refer to this document only if your use-cases cannot be satisfied by the customizations provided in the Advanced Push Configuration section.

If the push notification display is handled by the application we need some help from the application to show Push Campaign statistics namely Impressions and Clicks.

Tracking Notification Impressions

The application needs to notify the SDK if a push from the MoEngage Platform is received via Firebase Cloud Messaging(FCM). SDK provides a helper API to check whether push is received from the MoEngage Platform or not use this API to check if the received push is from the MoEngage Platform.

if (MoEPushHelper.getInstance().isFromMoEngagePlatform(pushPayload)) {
   MoEPushHelper.getInstance().logNotificationReceived(context, pushPayload)
if (MoEPushHelper.getInstance().isFromMoEngagePlatform(pushPayload)) {
   MoEPushHelper.getInstance().logNotificationReceived(context, pushPayload);

Tracking Notification Clicks

Once the notification is clicked application needs to notify the SDK that a notification is clicked for the SDK to track notification clicks.
For SDK to track notification clicks and user session accurately please make sure the Push payload received from FCM is added as extras to the Pending intent and the below API is called from onCreate() of your Activity which is inflated on notification click.

MoEPushHelper.getInstance().logNotificationClick(applicationContext, intent)
MoEPushHelper.getInstance().logNotificationClick(getApplicationContext(), getIntent());

Handling Silent Push

MoEngage Platform sends out silent notifications(notifications which shouldn't be shown to the end-user) for un-install tracking. When push payload is handled by the SDK no additional handling is required for Silent pushes. But since the application is handling push notification you would need to check for silent pushes and pass the payload to the MoEngage SDK.
This should be the first check before processing the push payload.

if (MoEPushHelper.getInstance().isFromMoEngagePlatform(pushPayload) && MoEPushHelper.getInstance().isSilentPush(pushPayload)){
      MoEPushHelper.getInstance().handlePushPayload(context, pushPayload)
// app logic to build and show notification
if (MoEPushHelper.getInstance().isFromMoEngagePlatform(pushPayload) && MoEPushHelper.getInstance().isSilentPush(pushPayload)) {
  MoEPushHelper.getInstance().handlePushPayload(context, pushPayload);
// app logic to build and show notification

Callback for push delivered by Push Amp

Push-Amp notification is not delivered via FCM, it is delivered directly via MoEngage. You need to set up a callback for receiving payload for messages/campaigns.

  1. Setup a callback for notification received. Refer to the documentation for more details.
  2. Mark notification as not required. This step is important, if not implemented correctly end-user might end-up with 2 notifications. Refer to the documentation for more details.
    In this case isNotificationRequired() should always return false.

Handling re-direction for push delivered by Push Amp+

Whenever campaigns are delivered via Push Amp+ due to a technical limitation push display cannot be handled by the application. The application will get a callback only once the user clicks on the notification. Refer to the documentation to learn more about how to register for push redirection callback.