PushMessageListener

open class PushMessageListener

This class is a callback for the push message delivery. In order to modify the behavior simply extend this class and override methods

Since

5.3

Author

Umang Chamaria

Constructors

PushMessageListener
Link copied to clipboard
fun PushMessageListener()

Functions

customizeNotification
Link copied to clipboard
open fun customizeNotification(notification: Notification, context: Context, payload: Bundle)

Callback to customise the notification object if required. SDK uses this method to add/customise a few settings like vibration, led color etc. Make sure you call super before adding your own customisation.

dismissNotificationAfterClick
Link copied to clipboard
fun dismissNotificationAfterClick(context: Context, payload: Bundle)

Forcefully dismisses a Notification posted to the status bar. This is required when action buttons are clicked since autoCancel does not work with action button

getIntentFlags
Link copied to clipboard
open fun getIntentFlags(payload: Bundle): Int

Get the intent flags for the redirection intent

getNotificationId
Link copied to clipboard
fun getNotificationId(context: Context, update: Boolean): Int
getRedirectIntent
Link copied to clipboard
open fun getRedirectIntent(context: Context): Intent

Returns the redirectIntent which will be started from the pending intent of the notification Note: Overriding this method and returning a custom intent will affect click tracking.

handleCustomAction
Link copied to clipboard
open fun handleCustomAction(context: Context?, payload: String)

Callback triggered for custom action.

isNotificationRequired
Link copied to clipboard
open fun isNotificationRequired(context: Context, payload: Bundle): Boolean

Return value of this method decides whether a notification should be shown or not. In case you are overriding this method ensure you call super(context, payload), notifications will not be shown if super is not called. Note: If the super(context, payload) returns false ensure that the method always returns false.

logCampaignImpression
Link copied to clipboard
fun logCampaignImpression(context: Context, payload: Bundle)

Logs impression for the notification if it was shown

logNotificationClicked
Link copied to clipboard
fun logNotificationClicked(context: Context?, intent: Intent?)

Tracks notification clicks on MoEngage Platform.

onCreateNotification
Link copied to clipboard
open fun onCreateNotification(context: Context, notificationPayload: NotificationPayload): NotificationCompat.Builder

Build the notification using NotificationCompat.Builder

onHandleRedirection
Link copied to clipboard
open fun onHandleRedirection(activity: Activity, payload: Bundle)

This method is used to redirect the user to a specific screen or URL on notification click.

onMessageReceived
Link copied to clipboard
fun onMessageReceived(context: Context, payload: Bundle)
fun onMessageReceived(context: Context, payloadMap: Map<String, String>)

Callback which is triggered when a push payload is received. This method is responsible for creating the notification object and posting the notification.

onNonMoEngageMessageReceived
Link copied to clipboard
open fun onNonMoEngageMessageReceived(context: Context, payload: Bundle)

To get a callback for push not sent via MoEngage Platform.

onNotificationCleared
Link copied to clipboard
open fun onNotificationCleared(context: Context, payload: Bundle)

Callback triggered when notification is cleared from the device's notification drawer.

onNotificationNotRequired
Link copied to clipboard
open fun onNotificationNotRequired(context: Context, payload: Bundle)

Callback triggered whenever notification is not shown by the SDK.

onNotificationReceived
Link copied to clipboard
open fun onNotificationReceived(context: Context, payload: Bundle)

Callback triggered whenever notification is received by the application.