Notification.getPayload()
Note: This API is supported from version 7.1.0.
The ZohoSalesIQ.Notification.getPayload() API parses the map that was received from the Firebase push message to the SalesIQNotificationPayload object. This API can be used when the notifications need to be created on your own. This API needs to be handled using the onMessageReceived() method of your FirebaseMessagingService class.
Syntax
CopiedZohoSalesIQ.Notification.getPayload(Map<String, String> data, ZohoSalesIQResultCallback<SalesIQNotificationPayload> callback)
Example
Copied @Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Map<String, String> extras = remoteMessage.getData();
if (ZohoSalesIQ.Notification.isZohoSalesIQNotification(extras)) {
ZohoSalesIQ.Notification.getPayload(extras, result -> {
SalesIQNotificationPayload payload = result.getData();
if (payload instanceof SalesIQNotificationPayload.Chat) {
SalesIQNotificationPayload.Chat chatMessagePayload = (SalesIQNotificationPayload.Chat) payload;
// Handle chat message notification here
} else if (payload instanceof SalesIQNotificationPayload.VisitorHistory) {
SalesIQNotificationPayload.VisitorHistory visitorHistoryPayload = (SalesIQNotificationPayload.VisitorHistory) payload;
// Handle visitor history notification here
} else if (payload instanceof SalesIQNotificationPayload.EndChatDetails) {
SalesIQNotificationPayload.EndChatDetails endChatDetailsPayload = (SalesIQNotificationPayload.EndChatDetails) payload;
// Handle end chat notification here
} else {
ZohoSalesIQ.Notification.handle(getApplication(), extras);
}
});
} else {
// Handle your app's push messages here
}
}
Copied override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
val extras = remoteMessage.data
if (ZohoSalesIQ.Notification.isZohoSalesIQNotification(extras)) {
ZohoSalesIQ.Notification.getPayload(extras) { result: SalesIQResult<SalesIQNotificationPayload> ->
when (val payload = result.data) {
is SalesIQNotificationPayload.Chat -> {
val chatMessagePayload: SalesIQNotificationPayload.Chat = payload
// Handle chat message notification here
}
is SalesIQNotificationPayload.VisitorHistory -> {
val visitorHistoryPayload: SalesIQNotificationPayload.VisitorHistory = payload
// Handle visitor history notification here
}
is SalesIQNotificationPayload.EndChatDetails -> {
val endChatDetailsPayload: SalesIQNotificationPayload.EndChatDetails = payload
// Handle end chat notification here
}
else -> {
ZohoSalesIQ.Notification.handle(application, extras)
}
}
}
} else {
// Handle your app's push messages here
}
}