Chat Android SDK  7.0.1
com.twilio.chat.Message Class Reference

Representation of a Chat Message object. More...

Classes

class  Media
 Media object describes downloadable media inside chat message with type Message.Type.MEDIA. More...
 
class  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
native String getSid ()
 Returns the identifier for this message. More...
 
native String getAuthor ()
 The global identity of the author of this message. More...
 
native String getDateCreated ()
 The creation date for this message. More...
 
Date getDateCreatedAsDate ()
 The creation timestamp for this message. More...
 
native String getDateUpdated ()
 The timestamp when this message was updated last time. More...
 
Date getDateUpdatedAsDate ()
 The Date when this message was updated last time. More...
 
native String getLastUpdatedBy ()
 
String getMessageBody ()
 The body for this message. More...
 
String getChannelSid ()
 Returns the channel SID of the channel this message belongs to. More...
 
Channel getChannel ()
 Returns the parent channel this message belongs to. More...
 
String getMemberSid ()
 Returns the member SID of the member this message sent by. More...
 
Member getMember ()
 Returns the member this message sent by. More...
 
native Messages getMessages ()
 Returns the parent messages object this message belongs to. More...
 
native long getMessageIndex ()
 Returns the index number for this message. More...
 
Attributes getAttributes ()
 Retrieve attributes associated with this message. More...
 
native Type getType ()
 
boolean hasMedia ()
 Helper method to check if message has media type. More...
 
Media getMedia ()
 Get media descriptor of an associated media attachment, if exists. 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 Chat Message object.

Member Function Documentation

Attributes com.twilio.chat.Message.getAttributes ( )

Retrieve attributes associated with this message.

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

The global identity of the author of this message.

Returns
The global identity.
Channel com.twilio.chat.Message.getChannel ( )

Returns the parent channel this message belongs to.

Returns
Channel.
String com.twilio.chat.Message.getChannelSid ( )

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

Returns
Channel SID.
native String com.twilio.chat.Message.getDateCreated ( )

The creation date for this message.

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

The creation timestamp for this message.

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

The timestamp when this message was updated last time.

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

The Date when this message was updated last time.

Returns
Most recent Date when this message was updated or null.
native String com.twilio.chat.Message.getLastUpdatedBy ( )
Returns
The identity of the user who updated the message.
Media com.twilio.chat.Message.getMedia ( )

Get media descriptor of an associated media attachment, if exists.

If the message type is TEXT this method will return null.

Returns
Media descriptor with all information about the media including the output stream to write it to. Or null if no media is available.
Member com.twilio.chat.Message.getMember ( )

Returns the member this message sent by.

Returns
Member.
String com.twilio.chat.Message.getMemberSid ( )

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

Returns
Member SID.
String com.twilio.chat.Message.getMessageBody ( )

The body for this message.

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

Returns the index number for this message.

By design of the chat 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 consumption horizon API. See Channel#getUnconsumedMessagesCount for details.

Returns
the message index.
native Messages com.twilio.chat.Message.getMessages ( )

Returns the parent messages object this message belongs to.

Returns
Messages.
native String com.twilio.chat.Message.getSid ( )

Returns the identifier for this message.

Returns
The message SID.
native Type com.twilio.chat.Message.getType ( )
Returns
message type. If message has media type then getMedia shall return the descriptor for the attached media.
boolean com.twilio.chat.Message.hasMedia ( )

Helper method to check if message has media type.

Returns
true if message has type MEDIA, false otherwise.
if (message.hasMedia()) {
Message.Media media = message.getMedia();
}
static Options com.twilio.chat.Message.options ( )
static

Options builder.

Use for constructing new message options in Messages#sendMessage.

Returns
New empty Options object.
Message.options()
.withMedia(new FileInputStream("/path/to/Somefile.txt"), "text/plain")
.withMediaFileName("file.txt");
void com.twilio.chat.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.chat.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.