Chat Android SDK  5.1.0
com.twilio.chat.NotificationPayload Class Reference

Helper accessor for notification data payload bundle as received from Twilio Notifications. More...

Classes

enum  Type
 Represents payload type. More...
 

Public Member Functions

 NotificationPayload (Bundle data)
 Create notification payload from the received bundle. More...
 
 NotificationPayload (Map< String, String > remoteMessage)
 Create notification payload from the received map. More...
 
Getters
Type getType ()
 Get notification type. More...
 
String getAuthor ()
 Get NEW_MESSAGE notification author. More...
 
String getBody ()
 Get NEW_MESSAGE notification body. More...
 
String getChannelTitle ()
 Get NEW_MESSAGE notification channel title. More...
 
String getChannelSid ()
 Get NEW_MESSAGE notification channel SID. More...
 
String getMessageSid ()
 Get NEW_MESSAGE notification message SID. More...
 
String getSound ()
 Get notification sound. More...
 

Detailed Description

Helper accessor for notification data payload bundle as received from Twilio Notifications.

Use in GcmListener.onMessageReceived() implementation to retrieve Twilio-generated payload fields safely.

Do not access the fields in the bundle directly - they could be modified without notice, always use this helper to access them.

Constructor & Destructor Documentation

com.twilio.chat.NotificationPayload.NotificationPayload ( Bundle  data)

Create notification payload from the received bundle.

Parameters
dataAndroid Bundle with push notification data as received from the system.

Example:

public class GCMListenerService extends GcmListenerService {
@Override
public void onMessageReceived(String from, Bundle data) {
NotificationPayload payload(data);
// Do the processing here
}
}
com.twilio.chat.NotificationPayload.NotificationPayload ( Map< String, String >  remoteMessage)

Create notification payload from the received map.

Parameters
remoteMessageAndroid FCM RemoteMessage with push notification data as received from the system.

Example:

public class FCMListenerService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
NotificationPayload payload(remoteMessage.getData());
// Do the processing here
}
}

Member Function Documentation

String com.twilio.chat.NotificationPayload.getAuthor ( )

Get NEW_MESSAGE notification author.

Returns
Message author for NEW_MESSAGE notification type, empty string otherwise.
String com.twilio.chat.NotificationPayload.getBody ( )

Get NEW_MESSAGE notification body.

Returns
Message body as configured by the push notification configuration in service.
String com.twilio.chat.NotificationPayload.getChannelSid ( )

Get NEW_MESSAGE notification channel SID.

Returns
Channel SID for NEW_MESSAGE notification type, empty string otherwise.
String com.twilio.chat.NotificationPayload.getChannelTitle ( )

Get NEW_MESSAGE notification channel title.

Returns
Channel title for NEW_MESSAGE notification type, empty string otherwise.
String com.twilio.chat.NotificationPayload.getMessageSid ( )

Get NEW_MESSAGE notification message SID.

Returns
Message SID for NEW_MESSAGE notification type, empty string otherwise.
String com.twilio.chat.NotificationPayload.getSound ( )

Get notification sound.

Returns
Sound name as configured by the push notification configuration in service, empty string if not configured.
Type com.twilio.chat.NotificationPayload.getType ( )

Get notification type.

Returns
received notification type as a Type enum.