Conversations Android SDK  1.0.1
com.twilio.conversations.Message Interface Reference

Representation of a Conversations Message object. More...

Classes

interface  Options
 Used to construct new message before sending. More...
 
enum  Type
 Represents the type of message. More...
 
enum  UpdateReason
 Indicates reason for message update. More...
 

Public Member Functions

Getters
String getSid ()
 Returns the identifier for this message. More...
 
String getAuthor ()
 The global identity of the author of this message. More...
 
String getDateCreated ()
 The creation date for this message. More...
 
Date getDateCreatedAsDate ()
 The creation timestamp for this message. More...
 
String getDateUpdated ()
 The timestamp when this message was updated last time. More...
 
Date getDateUpdatedAsDate ()
 The Date when this message was updated last time. More...
 
String getLastUpdatedBy ()
 
String getMessageBody ()
 The body for this message. More...
 
String getConversationSid ()
 Returns the conversation SID of the conversation this message belongs to. More...
 
Conversation getConversation ()
 Returns the parent conversation this message belongs to. More...
 
String getParticipantSid ()
 Returns the participant SID of the participant this message sent by. More...
 
Participant getParticipant ()
 Returns the participant this message sent by. More...
 
long getMessageIndex ()
 Returns the index number for this message. More...
 
Attributes getAttributes ()
 Retrieve attributes associated with this message. More...
 
Type getType ()
 
AggregatedDeliveryReceipt getAggregatedDeliveryReceipt ()
 
boolean hasMedia ()
 Helper method to check if message has media type. More...
 
String getMediaSid ()
 Get SID of media stream. More...
 
String getMediaFileName ()
 Get file name of media stream. More...
 
String getMediaType ()
 Get mime-type of media stream. More...
 
long getMediaSize ()
 Get size of media stream. More...
 
void getMediaContentTemporaryUrl (CallbackListener< String > listener)
 Request media download temporary link. More...
 
Setters
void updateMessageBody (String body, StatusListener listener)
 Updates the body for a message. More...
 
void setAttributes (Attributes attributes, StatusListener listener)
 Set attributes associated with this message. More...
 

Static Public Member Functions

Builders
static Options options ()
 Options builder. More...
 

Detailed Description

Representation of a Conversations Message object.

Member Function Documentation

AggregatedDeliveryReceipt com.twilio.conversations.Message.getAggregatedDeliveryReceipt ( )
Returns
AggregatedDeliveryReceipt for the message.
Attributes com.twilio.conversations.Message.getAttributes ( )

Retrieve attributes associated with this message.

Returns
the message Attributes.
String com.twilio.conversations.Message.getAuthor ( )

The global identity of the author of this message.

Returns
The global identity.
Conversation com.twilio.conversations.Message.getConversation ( )

Returns the parent conversation this message belongs to.

Returns
Conversation.
String com.twilio.conversations.Message.getConversationSid ( )

Returns the conversation SID of the conversation this message belongs to.

Returns
Conversation SID.
String com.twilio.conversations.Message.getDateCreated ( )

The creation date for this message.

Returns
The timestamp when this message was created.
Date com.twilio.conversations.Message.getDateCreatedAsDate ( )

The creation timestamp for this message.

Returns
Date when this message was created or null if date string could not be parsed.
String com.twilio.conversations.Message.getDateUpdated ( )

The timestamp when this message was updated last time.

Returns
Most recent timestamp when this message was updated.
Date com.twilio.conversations.Message.getDateUpdatedAsDate ( )

The Date when this message was updated last time.

Returns
Most recent Date when this message was updated or null.
String com.twilio.conversations.Message.getLastUpdatedBy ( )
Returns
The identity of the user who updated the message.
void com.twilio.conversations.Message.getMediaContentTemporaryUrl ( CallbackListener< String >  listener)

Request media download temporary link.

This URL is impermanent, it expires in several minutes. If the link became invalid (expired), need to re-request the new one. It is user's responsibility to timely download media data by this link.

Parameters
listenerListener to receive temporary URL.
Exceptions
IllegalStateExceptionWhen hasMedia returns false.
String com.twilio.conversations.Message.getMediaFileName ( )

Get file name of media stream.

Returns
file name of media stream.
Exceptions
IllegalStateExceptionWhen hasMedia returns false.
String com.twilio.conversations.Message.getMediaSid ( )

Get SID of media stream.

Returns
SID of media stream.
Exceptions
IllegalStateExceptionWhen hasMedia returns false.
long com.twilio.conversations.Message.getMediaSize ( )

Get size of media stream.

Returns
size of media stream.
Exceptions
IllegalStateExceptionWhen hasMedia returns false.
String com.twilio.conversations.Message.getMediaType ( )

Get mime-type of media stream.

Returns
mime-type string of media stream.
Exceptions
IllegalStateExceptionWhen hasMedia returns false.
String com.twilio.conversations.Message.getMessageBody ( )

The body for this message.

Returns
The message body.
long com.twilio.conversations.Message.getMessageIndex ( )

Returns the index number for this message.

By design of the conversations system the message indices may have arbitrary gaps between them, that does not necessarily mean they were deleted or otherwise modified - just that messages may have non-contiguous indices even if they are sent immediately one after another.

Trying to use indices for some calculations is going to be unreliable.

To calculate the number of unread messages it is better to use the read horizon API. See Conversation#getUnreadMessagesCount for details.

Returns
the message index.
Participant com.twilio.conversations.Message.getParticipant ( )

Returns the participant this message sent by.

Returns
Participant.
String com.twilio.conversations.Message.getParticipantSid ( )

Returns the participant SID of the participant this message sent by.

Returns
Participant SID.
String com.twilio.conversations.Message.getSid ( )

Returns the identifier for this message.

Returns
The message SID.
Type com.twilio.conversations.Message.getType ( )
Returns
message type.
boolean com.twilio.conversations.Message.hasMedia ( )

Helper method to check if message has media type.

Returns
true if message has type MEDIA, false otherwise.

Example

if (message.hasMedia()) {
String fileName = message.getMediaFileName();
}
static Options com.twilio.conversations.Message.options ( )
static

Options builder.

Use for constructing new message options in Conversation#sendMessage.

Returns
New empty Options object.

Example

Message.options()
.withMedia(new FileInputStream("/path/to/Somefile.txt"), "text/plain")
.withMediaFileName("file.txt");
void com.twilio.conversations.Message.setAttributes ( Attributes  attributes,
StatusListener  listener 
)

Set attributes associated with this message.

Passing null will reset message attributes to an empty json object.

Parameters
attributesThe new developer-provided Attributes for this message.
listenerListener that will receive callback with the result.
void com.twilio.conversations.Message.updateMessageBody ( String  body,
StatusListener  listener 
)

Updates the body for a message.

Parameters
bodyThe body for the message.
listenerListener that will receive callback of the result.