hyphenate_SDK4.0 5.0.0
hyphenate java IM SDK
 
Loading...
Searching...
No Matches
com.hyphenate.chat.EMMessage Class Reference

Classes

enum  ChatType
 
enum  Direct
 
enum  EMStreamStatus
 
enum  Status
 
enum  Type
 

Public Member Functions

Status status ()
 
void setStatus (Status status)
 
Type getType ()
 
synchronized EMMessageBody getBody ()
 
EMStreamChunk getStreamChunk ()
 
long getMsgTime ()
 
void setMsgTime (long msgTime)
 
long localTime ()
 
void setLocalTime (long serverTime)
 
boolean isNeedReadReceipt ()
 
void setIsNeedReadReceipt (boolean need)
 
int readReceiptCount ()
 
void setIsChatThreadMessage (boolean isChatThreadMessage)
 
boolean isChatThreadMessage ()
 
EMChatThread getChatThread ()
 
void setBody (EMMessageBody body)
 
void addBody (EMMessageBody body)
 
String getFrom ()
 
void setFrom (String from)
 
void setTo (String to)
 
String getTo ()
 
String getMsgId ()
 
void setMsgId (String msgId)
 
synchronized void setMessageStatusCallback (EMCallBack callback)
 
void setAttribute (String attribute, boolean value)
 
void setAttribute (String attribute, int value)
 
void setAttribute (String attribute, long value)
 
void setAttribute (String attribute, float value)
 
void setAttribute (String attribute, double value)
 
void setAttribute (String attribute, JSONObject value)
 
void setAttribute (String attribute, JSONArray value)
 
void setAttribute (String attribute, String value)
 
boolean getBooleanAttribute (String attribute) throws HyphenateException
 
boolean getBooleanAttribute (String attribute, boolean defaultValue)
 
int getIntAttribute (String attribute, int defaultValue)
 
long getLongAttribute (String attribute, long defaultValue)
 
float getFloatAttribute (String attribute, float defaultValue)
 
double getDoubleAttribute (String attribute, double defaultValue)
 
int getIntAttribute (String attribute) throws HyphenateException
 
long getLongAttribute (String attribute) throws HyphenateException
 
float getFloatAttribute (String attribute) throws HyphenateException
 
double getDoubleAttribute (String attribute) throws HyphenateException
 
String getStringAttribute (String attribute) throws HyphenateException
 
String getStringAttribute (String attribute, String defaultValue)
 
JSONObject getJSONObjectAttribute (String attribute) throws HyphenateException
 
JSONArray getJSONArrayAttribute (String attribute) throws HyphenateException
 
ChatType getChatType ()
 
void setChatType (ChatType chatType)
 
boolean isPeerRead ()
 
boolean isDelivered ()
 
void setDelivered (boolean isDelivered)
 
boolean isRead ()
 
boolean isListened ()
 
void setListened (boolean isListened)
 
void setDeliverAcked (boolean isDeliverAcked)
 
int progress ()
 
void setProgress (int progress)
 
Direct direct ()
 
void setDirection (Direct dir)
 
String conversationId ()
 
Map< String, Object > ext ()
 
Map< String, Object > getAttributes ()
 
List< EMMessageReactiongetMessageReaction ()
 
boolean isOnlineState ()
 
void setPriority (EMChatRoomMessagePriority priority)
 
boolean isDeliverOnlineOnly ()
 
void deliverOnlineOnly (boolean onlineOnly)
 
void setWebhookEnv (String webhookEnv)
 
String getWebhookEnv ()
 
void setReceiverList (List< String > receiverList)
 
List< String > receiverList ()
 
boolean isBroadcast ()
 
boolean isContentReplaced ()
 
EMMessagePinInfo pinnedInfo ()
 
EMSenderInfo getSenderInfo ()
 

Static Public Member Functions

static EMMessage createSendMessage (Type type)
 
static EMMessage createReceiveMessage (Type type)
 
static EMMessage createTextSendMessage (String content, String username)
 
static EMMessage createVoiceSendMessage (String filePath, int timeLength, String username)
 
static EMMessage createVoiceSendMessage (Uri filePath, int timeLength, String username)
 
static EMMessage createImageSendMessage (String filePath, boolean sendOriginalImage, String username)
 
static EMMessage createGifImageMessage (String gifImageFilePath, String username)
 
static EMMessage createImageSendMessage (Uri imgUri, boolean sendOriginalImage, String username)
 
static EMMessage createVideoSendMessage (String videofilePath, String imageThumbPath, int timeLength, String username)
 
static EMMessage createVideoSendMessage (Uri videofilePath, String imageThumbPath, int timeLength, String username)
 
static EMMessage createVideoSendMessage (Uri videofilePath, Uri imageThumbPath, int timeLength, String username)
 
static EMMessage createLocationSendMessage (double latitude, double longitude, String locationAddress, String buildingName, String username)
 
static EMMessage createLocationSendMessage (double latitude, double longitude, String locationAddress, String username)
 
static EMMessage createFileSendMessage (String filePath, String username)
 
static EMMessage createFileSendMessage (Uri filePath, String username)
 
static EMMessage createCombinedSendMessage (String title, String summary, String compatibleText, List< String > messageIdList, String userId)
 

Detailed Description

The message instance, which indicates a sent or received message.

For example: Constructs a text message to send:

EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.TXT);
msg.setTo("user1");
TextMessageBody body = new TextMessageBody("hello from hyphenate sdk");
msg.addBody(body);
void setTo(String to)
Definition EMMessage.java:1311
void addBody(EMMessageBody body)
Definition EMMessage.java:1261

Constructs an image message to send:

EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.IMAGE);
msg.setTo("user1");
ImageMessageBody body = new ImageMessageBody(imageFileUrl);
msg.addBody(body);
static EMMessage createSendMessage(Type type)
Definition EMMessage.java:686

Member Function Documentation

◆ addBody()

void com.hyphenate.chat.EMMessage.addBody ( EMMessageBody body)

Adds a message body.

This method is equivalent to EMMessage#setBody(EMMessageBody) which sets the message body. The latter is recommended.

Only one message body can be added for one message.

Parameters
bodyThe message body.

◆ conversationId()

String com.hyphenate.chat.EMMessage.conversationId ( )

Gets the conversation ID.

Returns
The conversation ID.

◆ createCombinedSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createCombinedSendMessage ( String title,
String summary,
String compatibleText,
List< String > messageIdList,
String userId )
static

Creates a combined message for sending.

The SDKs that do not support combined messages will parse this type of message as a text message Type#TXT by resolving the value of compatibleText into the content of the text message and igoring other fields. and the content of the message will be from compatibleText, and other fields will be ignored.

Parameters
titleThe title of the combined message. It can be null or an empty string ("").
summaryThe summary of the combined message. It can be null or an empty string ("").
compatibleTextThe compatible text of the combined message. It can be null or an empty string ("").
messageIdListThe list cannot be null or empty. It can contain a maximum of 300 message IDs. When you call EMChatManager#sendMessage(EMMessage) to send a message, the SDK will check the setting of this field.
userIdThe message recipient. The field setting is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The combined message instance.

◆ createFileSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createFileSendMessage ( String filePath,
String username )
static

Creates a file message for sending.

Parameters
filePathThe file path.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createFileSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createFileSendMessage ( Uri filePath,
String username )
static

Creates a file message for sending.

Parameters
filePathThe file path.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createGifImageMessage()

static EMMessage com.hyphenate.chat.EMMessage.createGifImageMessage ( String gifImageFilePath,
String username )
static

Creates a GIF image message for sending.

GIF images cannot be compressed and are always sent in their original size.

Parameters
gifImageFilePathThe URI of the GIF image.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createImageSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( String filePath,
boolean sendOriginalImage,
String username )
static

Creates an image message for sending.

Parameters
filePathThe image path.
sendOriginalImageWhether to send the original image.
  • true: Yes.
  • false: If the image is smaller than 100 KB, the SDK sends the original image. If the image is equal to or greater than 100 KB, the SDK will compress it before sending the compressed image.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createImageSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( Uri imgUri,
boolean sendOriginalImage,
String username )
static

Creates an image message for sending.

Parameters
imgUriThe URI of the image.
sendOriginalImageWhether to send the original image.
  • true: Yes.
  • false: If the image is smaller than 100 KB, the SDK sends the original image. If the image is equal to or greater than 100 KB, the SDK will compress it before sending the compressed image.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createLocationSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createLocationSendMessage ( double latitude,
double longitude,
String locationAddress,
String buildingName,
String username )
static

Creates a location message for sending.

Parameters
latitudeThe latitude.
longitudeThe longitude.
locationAddressThe location details.
buildingNameThe name of the building.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createLocationSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createLocationSendMessage ( double latitude,
double longitude,
String locationAddress,
String username )
static

Creates a location message for sending.

Parameters
latitudeThe latitude.
longitudeThe longitude.
locationAddressThe location details.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createReceiveMessage()

static EMMessage com.hyphenate.chat.EMMessage.createReceiveMessage ( Type type)
static

Creates a received message instance.

Parameters
typeThe message type.
Returns
The message instance.

◆ createSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createSendMessage ( Type type)
static

Creates a message instance for sending.

Parameters
typeThe message type.
Returns
The message instance.

◆ createTextSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createTextSendMessage ( String content,
String username )
static

Creates a text message for sending.

Parameters
contentThe text content.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createVideoSendMessage() [1/3]

static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( String videofilePath,
String imageThumbPath,
int timeLength,
String username )
static

Creates a video message for sending.

Parameters
videofilePathThe path of the video file.
imageThumbPathThe path of thumbnail of the first frame of the video.
timeLengthThe video duration in seconds.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createVideoSendMessage() [2/3]

static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( Uri videofilePath,
String imageThumbPath,
int timeLength,
String username )
static

Creates a video message for sending.

Parameters
videofilePathThe path of the video file.
imageThumbPathThe path of the thumbnail of the first frame of the video.
timeLengthThe video duration in seconds.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createVideoSendMessage() [3/3]

static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( Uri videofilePath,
Uri imageThumbPath,
int timeLength,
String username )
static

Creates a video message for sending.

Parameters
videofilePathThe path of the video file.
imageThumbPathThe path of the thumbnail of the first frame of the video.
timeLengthThe video duration in seconds.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createVoiceSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( String filePath,
int timeLength,
String username )
static

Creates a voice message for sending.

Parameters
filePathThe path of the voice file.
timeLengthThe voice duration in seconds.
usernameThe message sender is determined by the conversation type:
  • One-to-one chat: The peer user ID.
  • Group chat: The group ID.
  • Thread conversation: The message thread ID.
  • Chat room chat: The chat room ID.
Returns
The message instance.

◆ createVoiceSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( Uri filePath,
int timeLength,
String username )
static

Creates a voice message for sending.

Parameters
filePathThe URI of the voice file.
timeLengthThe voice duration in seconds.
usernameThe user ID of the message recipient or group ID.
Returns
The message instance.

◆ deliverOnlineOnly()

void com.hyphenate.chat.EMMessage.deliverOnlineOnly ( boolean onlineOnly)

Sets whether the message is delivered only when the recipient(s) is/are online.

Parameters
onlineOnlyWhether the message is delivered only when the recipient(s) is/are online:
  • true:The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
  • (Default) false:The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.

◆ direct()

Direct com.hyphenate.chat.EMMessage.direct ( )

The message direction.

  • SEND: This message is sent from the local client.
  • RECEIVE: The message is received by the local client.
Returns
The message direction. See Direct.

◆ ext()

Map< String, Object > com.hyphenate.chat.EMMessage.ext ( )

Gets all message extension fields. The return type is Map<String, Object>.

Returns
All message extension fields which are returned as a Map collection, Map<String, Object>. The Map collection contains key-value pairs where the key is the type (Boolean, Integer, Long, Float, Double, or String) of the extension field, and the value is the name of the extension field. If JsonObject is passed as the extension field type, it is returned as String.

◆ getAttributes()

Map< String, Object > com.hyphenate.chat.EMMessage.getAttributes ( )

Gets all extension fields of the message.

Returns
All extension fields in the message are returned as a Map collection of the Map<String, Object> type. The Map collection contains key-value pairs where the key is the data type (Boolean, Integer, Long, Float, Double, String, JsonObject, or JsonArray) of an extension field, and the value is the field name.

◆ getBody()

synchronized EMMessageBody com.hyphenate.chat.EMMessage.getBody ( )

Gets the message body.

Returns
The message body.

◆ getBooleanAttribute() [1/2]

boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the Boolean type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getBooleanAttribute() [2/2]

boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String attribute,
boolean defaultValue )

Gets a message extension attribute of the Boolean type.

Parameters
attributeThe attribute name.
defaultValueThe default value of the attribute.
Returns
The attribute value.

◆ getChatThread()

EMChatThread com.hyphenate.chat.EMMessage.getChatThread ( )

Gets the overview of the message thread.

The overview of the message thread exists only after you creates a message thread.

Returns
The overview of the message thread.

◆ getChatType()

ChatType com.hyphenate.chat.EMMessage.getChatType ( )

Gets the chat type.

Returns
The chat type.

◆ getDoubleAttribute() [1/2]

double com.hyphenate.chat.EMMessage.getDoubleAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the double type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getDoubleAttribute() [2/2]

double com.hyphenate.chat.EMMessage.getDoubleAttribute ( String attribute,
double defaultValue )

Gets a message extension attribute of the Double type.

Parameters
attributeThe attribute name.
defaultValueThe default value of the attribute.
Returns
The attribute value.

◆ getFloatAttribute() [1/2]

float com.hyphenate.chat.EMMessage.getFloatAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the Float type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getFloatAttribute() [2/2]

float com.hyphenate.chat.EMMessage.getFloatAttribute ( String attribute,
float defaultValue )

Gets a message extension attribute of the Float type.

Parameters
attributeThe attribute name.
defaultValueThe default value of the attribute.
Returns
The attribute value.

◆ getFrom()

String com.hyphenate.chat.EMMessage.getFrom ( )

Gets the user ID of the message sender.

Returns
The user ID of the message sender.

◆ getIntAttribute() [1/2]

int com.hyphenate.chat.EMMessage.getIntAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the Int type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getIntAttribute() [2/2]

int com.hyphenate.chat.EMMessage.getIntAttribute ( String attribute,
int defaultValue )

Gets a message extension attribute of the Int type.

Parameters
attributeThe attribute name.
defaultValueThe default value of the attribute.
Returns
The attribute value.

◆ getJSONArrayAttribute()

JSONArray com.hyphenate.chat.EMMessage.getJSONArrayAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the JSONArray type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getJSONObjectAttribute()

JSONObject com.hyphenate.chat.EMMessage.getJSONObjectAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the JSONObject type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getLongAttribute() [1/2]

long com.hyphenate.chat.EMMessage.getLongAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the Long type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getLongAttribute() [2/2]

long com.hyphenate.chat.EMMessage.getLongAttribute ( String attribute,
long defaultValue )

Gets a message extension attribute of the Long type.

Parameters
attributeThe attribute name.
defaultValueThe default value of the attribute.
Returns
The attribute value.

◆ getMessageReaction()

List< EMMessageReaction > com.hyphenate.chat.EMMessage.getMessageReaction ( )

Gets the list of Reactions.

Returns
The list of Reactions.

◆ getMsgId()

String com.hyphenate.chat.EMMessage.getMsgId ( )

Gets the message ID.

Returns
The message ID.

◆ getMsgTime()

long com.hyphenate.chat.EMMessage.getMsgTime ( )

Gets the Unix timestamp when the server receives the message.

Returns
The Unix timestamp when the server receives the message.

◆ getSenderInfo()

EMSenderInfo com.hyphenate.chat.EMMessage.getSenderInfo ( )

Gets the information of the message sender.

Returns
The information of the message sender, including the nickname, avatar, name card in the group, and remarks of the sender.

◆ getStreamChunk()

EMStreamChunk com.hyphenate.chat.EMMessage.getStreamChunk ( )

Get stream message chunk.

If this is a stream message, returns the corresponding stream chunk object; otherwise returns null.

Returns
Stream chunk if this is a stream message, null otherwise.

◆ getStringAttribute() [1/2]

String com.hyphenate.chat.EMMessage.getStringAttribute ( String attribute) throws HyphenateException

Gets a message extension attribute of the String type.

Parameters
attributeThe attribute name.
Returns
The attribute value.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getStringAttribute() [2/2]

String com.hyphenate.chat.EMMessage.getStringAttribute ( String attribute,
String defaultValue )

Gets a message extension attribute of the String type.

Parameters
attributeThe attribute name.
defaultValueThe default value of the attribute.
Returns
The attribute value.

◆ getTo()

String com.hyphenate.chat.EMMessage.getTo ( )

Gets the user ID of the message recipient:

  • one-to-one chat: The user ID of the message recipient.
  • Group chat: The group ID.
  • Chat room: Chat room ID.
Returns
The user ID of the message recipient.

◆ getType()

Type com.hyphenate.chat.EMMessage.getType ( )

Gets the chat message type.

Returns
The chat message type.

◆ getWebhookEnv()

String com.hyphenate.chat.EMMessage.getWebhookEnv ( )

Gets the environment identifier for callback routing.

Returns
The environment identifier for callback routing. Returns null if not set.

◆ isBroadcast()

boolean com.hyphenate.chat.EMMessage.isBroadcast ( )

Whether it is a global broadcast message for chat rooms under an app.

  • true: Yes.
  • false: No.
Returns
Whether it is a global broadcast message for chat rooms under an app.

◆ isChatThreadMessage()

boolean com.hyphenate.chat.EMMessage.isChatThreadMessage ( )

Gets whether the message is a threaded message.

Returns
Whether the message is a threaded message.
  • true: Yes.
  • false: No.

◆ isContentReplaced()

boolean com.hyphenate.chat.EMMessage.isContentReplaced ( )

Whether the message content is replaced.

  • true: Yes.
  • false: No.
Returns
Whether the message content is replaced.

◆ isDelivered()

boolean com.hyphenate.chat.EMMessage.isDelivered ( )

Gets whether the message is successfully delivered.

Returns
Whether the message is successfully delivered: -true: Yes. -false: No.

◆ isDeliverOnlineOnly()

boolean com.hyphenate.chat.EMMessage.isDeliverOnlineOnly ( )

Checks whether the message is delivered only when the recipient(s) is/are online.

Returns
- true: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
  • false: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.

◆ isListened()

boolean com.hyphenate.chat.EMMessage.isListened ( )

Gets whether the voice message is listened.

Returns
Whether the voice message is listened:
  • true: Yes.
  • false: No.

◆ isNeedReadReceipt()

boolean com.hyphenate.chat.EMMessage.isNeedReadReceipt ( )

Whether the message requires a read receipt. Set before sending.

Messages with this set to false cannot have read receipts sent for them. Applies to both one-to-one and group messages.

Returns
Whether the message requires a read receipt:
  • true: Yes;
  • (Default) false: No.

◆ isOnlineState()

boolean com.hyphenate.chat.EMMessage.isOnlineState ( )

Whether the message gets delivered to an online user.

Note
This field is issued by the server to indicate whether the recipient is online when the message is delivered.

This field is not stored in the local database. The value of this field is true by default for messages read from the database or pulled from the server.

Returns
Whether the recipient is online when the message is delivered.
  • (Default)true: Yes.
  • false: No. The recipient is offline.

◆ isPeerRead()

boolean com.hyphenate.chat.EMMessage.isPeerRead ( )

Gets whether the message is read by the peer.

Returns
Whether the message is read by the peer: -true: Yes. -false: No.

◆ isRead()

boolean com.hyphenate.chat.EMMessage.isRead ( )

Checks whether the message is read.

Returns
Whether the message is read: -true: Yes. -false: No.

◆ localTime()

long com.hyphenate.chat.EMMessage.localTime ( )

Gets the local timestamp of the message.

This method gets the timestamp when the message is created locally.

Returns
The local timestamp of the message.

◆ pinnedInfo()

EMMessagePinInfo com.hyphenate.chat.EMMessage.pinnedInfo ( )

Gets message pinning information.

Returns
Message pinning information.

◆ progress()

int com.hyphenate.chat.EMMessage.progress ( )

The progress for uploading or downloading a message attachment.

The upload or download progress is unavailable for the thumbnail of the message attachments.

Returns
The progress for uploading or downloading the message attachment. The value range is [0,100].

◆ readReceiptCount()

int com.hyphenate.chat.EMMessage.readReceiptCount ( )

Gets the read count of the message.

Returns
The read count of the message.

◆ receiverList()

List< String > com.hyphenate.chat.EMMessage.receiverList ( )

The recipient list of a targeted message.

Returns
The recipient list of a targeted message.

◆ setAttribute() [1/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
boolean value )

Sets a message extension attribute of the Boolean type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [2/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
double value )

Sets a message extension attribute of the Double type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [3/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
float value )

Sets a message extension attribute of the Float type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [4/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
int value )

Sets a message extension attribute of the Int type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [5/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
JSONArray value )

Sets a message extension attribute of the JSONArray type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [6/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
JSONObject value )

Sets a message extension attribute of the JSONObject type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [7/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
long value )

Sets a message extension attribute of the Long type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setAttribute() [8/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String attribute,
String value )

Sets a message extension attribute of the String type.

Parameters
attributeThe attribute name.
valueThe attribute value.

◆ setBody()

void com.hyphenate.chat.EMMessage.setBody ( EMMessageBody body)

(Recommended)Sets the message body.

Parameters
bodyThe message body.

◆ setChatType()

void com.hyphenate.chat.EMMessage.setChatType ( ChatType chatType)

Sets the chat type.

Parameters
chatTypeThe chat type. See ChatType.

◆ setDeliverAcked()

void com.hyphenate.chat.EMMessage.setDeliverAcked ( boolean isDeliverAcked)

Sets whether the message is delivered to the peer user.

The method is supposed to be called by the SDK instead of you.

Parameters
isDeliverAckedWhether the message is delivered to the peer user:
  • true: The message is delivered to the peer user.
  • false: The message has not been delivered to the peer user.

◆ setDelivered()

void com.hyphenate.chat.EMMessage.setDelivered ( boolean isDelivered)

Sets whether the message is successfully delivered.

The method is supposed to be called by the SDK instead of you.

Parameters
isDeliveredWhether the message is successfully delivered: -true: Yes. -false: No.

◆ setDirection()

void com.hyphenate.chat.EMMessage.setDirection ( Direct dir)

Sets the message direction.

Parameters
dirThe message direction. See Direct.

◆ setFrom()

void com.hyphenate.chat.EMMessage.setFrom ( String from)

Sets the user ID of the message sender.

Parameters
fromThe user ID of the message sender.

◆ setIsChatThreadMessage()

void com.hyphenate.chat.EMMessage.setIsChatThreadMessage ( boolean isChatThreadMessage)

Sets whether the message is a threaded message.

Parameters
isChatThreadMessageWhether the message is a threaded message:
  • true: Yes.
  • false: No.

◆ setIsNeedReadReceipt()

void com.hyphenate.chat.EMMessage.setIsNeedReadReceipt ( boolean need)

Sets whether the message requires a read receipt. Set before sending.

Applies to both one-to-one and group messages.

Parameters
needWhether the message requires a read receipt:
  • true: Yes;
  • (Default) false: No.

◆ setListened()

void com.hyphenate.chat.EMMessage.setListened ( boolean isListened)

Sets whether the voice message is listened.

The method is supposed to be called by the SDK instead of you.

Parameters
isListenedWhether the voice message is listened:
  • true: Yes.
  • false: No.

◆ setLocalTime()

void com.hyphenate.chat.EMMessage.setLocalTime ( long serverTime)

Sets the local timestamp of the message.

This method sets the timestamp when the message is created locally.

Parameters
serverTimeThe local timestamp of the message.

◆ setMessageStatusCallback()

synchronized void com.hyphenate.chat.EMMessage.setMessageStatusCallback ( EMCallBack callback)

Sets the message status change callback.

After the callback is triggered, the UI will be refreshed.

Parameters
callbackThe callback triggered when the message status changes.

◆ setMsgId()

void com.hyphenate.chat.EMMessage.setMsgId ( String msgId)

Sets the local message ID.

Parameters
msgIdSets the local message ID.

◆ setMsgTime()

void com.hyphenate.chat.EMMessage.setMsgTime ( long msgTime)

Sets the Unix timestamp when the server receives the message.

Parameters
msgTimeThe Unix timestamp when the server receives the message.

◆ setPriority()

void com.hyphenate.chat.EMMessage.setPriority ( EMChatRoomMessagePriority priority)

Sets the priority of the chat room message.

Parameters
priorityThe priority of the chat room message.

◆ setProgress()

void com.hyphenate.chat.EMMessage.setProgress ( int progress)

Sets the progress for uploading or downloading a message attachment.

Usually, you do not need to set the progress value. See EMMessage#progress().

Parameters
progressThe progress for uploading or downloading the message attachment. The value range is [0,100].

◆ setReceiverList()

void com.hyphenate.chat.EMMessage.setReceiverList ( List< String > receiverList)

Sets the recipient list of a targeted message.

This method is used only for groups and chat rooms. If this method is not called after a message is created, the message is sent to all members in the group or chat room.

Parameters
receiverListThe recipient list of a targeted message. If you pass in null, the messages are sent to all members in the group or chat room.

◆ setStatus()

void com.hyphenate.chat.EMMessage.setStatus ( Status status)

Sets the message sending or reception status.

Parameters
statusThe message sending or reception status.

◆ setTo()

void com.hyphenate.chat.EMMessage.setTo ( String to)

Sets the user ID of the message recipient.

Parameters
toThe user ID of the message recipient.

◆ setWebhookEnv()

void com.hyphenate.chat.EMMessage.setWebhookEnv ( String webhookEnv)

Sets the environment identifier for callback routing.

  • If this method is not called or null is passed, the server uses the default callback route.
  • If an empty string "" is passed, the server treats it as a blank identifier with no matching route.
  • If a valid string is passed, the server matches the specific callback route by the identifier.
Parameters
webhookEnvThe environment identifier for callback routing.

◆ status()

Status com.hyphenate.chat.EMMessage.status ( )

Gets the message sending or reception status.

Returns
The message sending or reception status.

The documentation for this class was generated from the following file: