Conversations Android SDK  1.0.1
com.twilio.conversations.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 (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 getConversationTitle ()
 Get NEW_MESSAGE notification conversation title. More...
 
String getConversationSid ()
 Get NEW_MESSAGE notification conversation SID. More...
 
String getMessageSid ()
 Get NEW_MESSAGE notification message SID. More...
 
long getMessageIndex ()
 Get NEW_MESSAGE notification message index. More...
 
String getSound ()
 Get notification sound. More...
 

Static Public Attributes

static final long INVALID_MESSAGE_INDEX = -1
 Value returned by getMessageIndex if notification contains no message index. More...
 

Detailed Description

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

Use in FirebaseMessagingService.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.conversations.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 = new NotificationPayload(remoteMessage.getData());
conversationsClient.handleNotification(payload);
// Do the processing here
}
}

Member Function Documentation

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

Get NEW_MESSAGE notification author.

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

Get NEW_MESSAGE notification body.

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

Get NEW_MESSAGE notification conversation SID.

Returns
Conversation SID for NEW_MESSAGE notification type, empty string otherwise.
String com.twilio.conversations.NotificationPayload.getConversationTitle ( )

Get NEW_MESSAGE notification conversation title.

Returns
Conversation title for NEW_MESSAGE notification type, empty string otherwise.
long com.twilio.conversations.NotificationPayload.getMessageIndex ( )

Get NEW_MESSAGE notification message index.

Returns
Message index for NEW_MESSAGE notification type, INVALID_MESSAGE_INDEX otherwise.
String com.twilio.conversations.NotificationPayload.getMessageSid ( )

Get NEW_MESSAGE notification message SID.

Returns
Message SID for NEW_MESSAGE notification type, empty string otherwise.
String com.twilio.conversations.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.conversations.NotificationPayload.getType ( )

Get notification type.

Returns
received notification type as a Type enum.

Member Data Documentation

final long com.twilio.conversations.NotificationPayload.INVALID_MESSAGE_INDEX = -1
static

Value returned by getMessageIndex if notification contains no message index.