Push Display Handled by Application
warning

Caution

This section is only required for very advanced use cases where the application needs to handle the push display on the client side. We believe that the 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 isFromMoEngagePlatform() 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 and call logNotificationReceived() to track notification impressions.

Kotlin Java
if (MoEPushHelper.getInstance().isFromMoEngagePlatform(pushPayload)) {
   MoEPushHelper.getInstance().logNotificationReceived(context, pushPayload)
}

Tracking Notification Clicks

After 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 sessions accurately, ensure:

  • the Push payload received from FCM is added as extras to the Pending intent 
  • The logNotificationClick() API is called from onCreate() of your Activity which is inflated on notification click.
Kotlin Java
MoEPushHelper.getInstance().logNotificationClick(applicationContext, intent)

Handling Silent Push

MoEngage Platform sends out silent notifications(notifications that are not displayed 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 notifications you would need to check for silent pushes and pass the payload to the MoEngage SDK.
The first check before processing the push payload is:

Kotlin Java
if (MoEPushHelper.getInstance().isFromMoEngagePlatform(pushPayload) && MoEPushHelper.getInstance().isSilentPush(pushPayload)){
      MoEFireBaseHelper.getInstance().passPushPayload(context, pushPayload)
      return
 }
// 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.

Steps:

  1. Setup a callback for notification received. For more information, refer to the notification received callback documentation.
  2. Mark notification as not required. This step is important, if not implemented correctly end-user might end up with two notifications. For more information, refer to the notification received callback documentation.

In this case isNotificationRequired() should always return false.

Handling re-direction for push delivered by Push Amp+

Whenever campaigns are delivered using Push Amp+ due to a technical limitation push display cannot be handled by the application. The application gets a callback only once the user clicks on the notification. For more information about how to register for push redirection callback, refer to the notification clicked callback documentation.

Related Documents

MoEngage Andriod Push Handling Samples

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?