showNotification

This method displays the custom view when a user is sent a push notification.

A Push Notification is a message that pops up on a mobile device. App publishers can send them at any time; users don't have to be in the app or using their devices to receive them.

There are various ways in which a Push Notification can be viewed: Standard and Extended. Standard provides a heading and image only; Extended provides a preview of the content.

The showNotification method will present the notification with the information passed in the parameters.

Method Signature

void showNotification(Bundle gcmData, Map<String, String> fcmData, int imageId)

Arguments

These are the arguments that define the method.

Name Type Mandatory Description
gcmData Bundle Mandatory Bundle is the GCM data that you receive in MyFirebaseMessagingService. It is null when the message is received from FCM.
fcmData Map Mandatory Map is the FCM data that you receive in MyFirebaseMessagingService. It is null when the message is received from GCM.
imageId Integer Optional The imageId which is in drawable folder. Passed imageId will be used as the notification icon.

Sample Code

if(Analytics.getInstance(this).pushNotificationWasSentFromHurree(bundle)){
    imageId = R.drawable.ic_launcher;
    /*
    * @bundle is the data you get from server for push notifictaion.
    *
    * @imageId is the image id which is in drawable folder,Passed imageId will be used as notification icon.
    * eg. imageId = R.drawable.ic_launcher;
    **/
    Analytics.getInstance(this).showNotification(null, fcmData, imageId);
}

results matching ""

    No results matching ""