Chat Android SDK  4.2.0
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...
 
String getMessageBody ()
 The body for this message. More...
 
native String getChannelSid ()
 Returns the channel SID of the channel this message belongs to. More...
 
native Channel getChannel ()
 Returns the parent channel this message belongs to. More...
 
native String getMemberSid ()
 Returns the member SID of the member this message sent by. More...
 
native 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...
 
JSONObject getAttributes () throws JSONException
 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 (JSONObject updatedAttributes, StatusListener listener)
 Change 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

JSONObject com.twilio.chat.Message.getAttributes ( ) throws JSONException

Retrieve attributes associated with this message.

Returns
the message attributes map.
Exceptions
JSONExceptionIf attributes could not be parsed.
native String com.twilio.chat.Message.getAuthor ( )

The global identity of the author of this message.

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

Returns the parent channel this message belongs to.

Returns
Channel.
native 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 time stamp 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
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.
native Member com.twilio.chat.Message.getMember ( )

Returns the member this message sent by.

Returns
Member.
native 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.

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 ( JSONObject  updatedAttributes,
StatusListener  listener 
)

Change attributes associated with this message.

Parameters
updatedAttributesMessage attributes map to fully replace old attributes.
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.