IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMMessage

Public Member Functions

 V2TIMMessage ()
 
String getMsgID ()
 
long getTimestamp ()
 
String getSender ()
 
String getNickName ()
 
String getFriendRemark ()
 
String getFaceUrl ()
 
String getNameCard ()
 
String getGroupID ()
 
String getUserID ()
 
int getStatus ()
 
int getElemType ()
 
V2TIMTextElem getTextElem ()
 
V2TIMCustomElem getCustomElem ()
 
V2TIMImageElem getImageElem ()
 
V2TIMSoundElem getSoundElem ()
 
V2TIMVideoElem getVideoElem ()
 
V2TIMFileElem getFileElem ()
 
V2TIMLocationElem getLocationElem ()
 
V2TIMFaceElem getFaceElem ()
 
V2TIMMergerElem getMergerElem ()
 
V2TIMGroupTipsElem getGroupTipsElem ()
 
String getLocalCustomData ()
 
void setLocalCustomData (String localCustomData)
 
int getLocalCustomInt ()
 
void setLocalCustomInt (int localCustomInt)
 
void setCloudCustomData (String data)
 
String getCloudCustomData ()
 
boolean isSelf ()
 
boolean isRead ()
 
boolean isPeerRead ()
 
boolean isNeedReadReceipt ()
 
void setNeedReadReceipt (boolean needReadReceipt)
 
boolean isBroadcastMessage ()
 
int getPriority ()
 
V2TIMOfflinePushInfo getOfflinePushInfo ()
 
List< String > getGroupAtUserList ()
 
long getSeq ()
 
long getRandom ()
 
boolean isExcludedFromUnreadCount ()
 
void setExcludedFromUnreadCount (boolean excludedFromUnreadCount)
 
boolean isExcludedFromLastMessage ()
 
void setExcludedFromLastMessage (boolean excludedFromLastMessage)
 
boolean isExcludedFromContentModeration ()
 
void setExcludedFromContentModeration (boolean excludedFromContentModeration)
 
String getCustomModerationConfigurationID ()
 
void setCustomModerationConfigurationID (String customModerationConfigurationID)
 
boolean isSupportMessageExtension ()
 
void setSupportMessageExtension (boolean supportExtension)
 
boolean hasRiskContent ()
 
V2TIMUserFullInfo getRevokerInfo ()
 
String getRevokeReason ()
 
V2TIMGroupMemberFullInfo getPinnerInfo ()
 
String toString ()
 

Static Public Attributes

static final int V2TIM_MSG_STATUS_SENDING = 1
 
static final int V2TIM_MSG_STATUS_SEND_SUCC = 2
 
static final int V2TIM_MSG_STATUS_SEND_FAIL = 3
 
static final int V2TIM_MSG_STATUS_HAS_DELETED = 4
 
static final int V2TIM_MSG_STATUS_LOCAL_IMPORTED = 5
 
static final int V2TIM_MSG_STATUS_LOCAL_REVOKED = 6
 
static final int V2TIM_PRIORITY_DEFAULT = 0
 
static final int V2TIM_PRIORITY_HIGH = 1
 
static final int V2TIM_PRIORITY_NORMAL = 2
 
static final int V2TIM_PRIORITY_LOW = 3
 
static final int V2TIM_ELEM_TYPE_NONE = 0
 
static final int V2TIM_ELEM_TYPE_TEXT = 1
 
static final int V2TIM_ELEM_TYPE_CUSTOM = 2
 
static final int V2TIM_ELEM_TYPE_IMAGE = 3
 
static final int V2TIM_ELEM_TYPE_SOUND = 4
 
static final int V2TIM_ELEM_TYPE_VIDEO = 5
 
static final int V2TIM_ELEM_TYPE_FILE = 6
 
static final int V2TIM_ELEM_TYPE_LOCATION = 7
 
static final int V2TIM_ELEM_TYPE_FACE = 8
 
static final int V2TIM_ELEM_TYPE_GROUP_TIPS = 9
 
static final int V2TIM_ELEM_TYPE_MERGER = 10
 
static final int V2TIM_RECEIVE_MESSAGE = 0
 
static final int V2TIM_NOT_RECEIVE_MESSAGE = 1
 
static final int V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE = 2
 
static final int V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT = 3
 
static final int V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ = 0
 
static final int V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD = 1
 

Constructor & Destructor Documentation

◆ V2TIMMessage()

V2TIMMessage ( )
inline

Member Function Documentation

◆ getMsgID()

String getMsgID ( )
inline

Get the message ID

Returns

◆ getTimestamp()

long getTimestamp ( )
inline

Get UTC timestamp of the message

Returns

◆ getSender()

String getSender ( )
inline

Get the userID of the message sender

Returns
Sender's userID

◆ getNickName()

String getNickName ( )
inline

Get the nickname of the message sender

Returns
Sender's nickname

◆ getFriendRemark()

String getFriendRemark ( )
inline

Get friend remarks. If friend information has not been pulled or the user is not a friend, null will be returned.

Returns
Friend remarks

◆ getFaceUrl()

String getFaceUrl ( )
inline

Get the sender's profile photo URL

Returns
Profile photo URL

◆ getNameCard()

String getNameCard ( )
inline

Get the message sender's alias in the group (valid for group messages)

Returns
Alias in the group

◆ getGroupID()

String getGroupID ( )
inline

Get the groupID. If the message is not a group message, null will be returned.

Returns
Group ID

◆ getUserID()

String getUserID ( )
inline

Get the ID of the other user for one-to-one messages (whether sent by the local or remote user). For group messages, null will be returned.

Returns

◆ getStatus()

int getStatus ( )
inline

Query the message status

Returns
Message sending status

◆ getElemType()

int getElemType ( )
inline

Get the message type

◆ getTextElem()

V2TIMTextElem getTextElem ( )
inline

Get the content of a text message (V2TIM_ELEM_TYPE_TEXT)

◆ getCustomElem()

V2TIMCustomElem getCustomElem ( )
inline

Get the content of a custom message (V2TIM_ELEM_TYPE_CUSTOM)

◆ getImageElem()

V2TIMImageElem getImageElem ( )
inline

Get the content of an image message (V2TIM_ELEM_TYPE_IMAGE)

◆ getSoundElem()

V2TIMSoundElem getSoundElem ( )
inline

Get the content of a voice message (V2TIM_ELEM_TYPE_SOUND)

◆ getVideoElem()

V2TIMVideoElem getVideoElem ( )
inline

Get the content of a video message (V2TIM_ELEM_TYPE_VIDEO)

◆ getFileElem()

V2TIMFileElem getFileElem ( )
inline

Get the content of a file message (V2TIM_ELEM_TYPE_FILE, fileElem)

◆ getLocationElem()

V2TIMLocationElem getLocationElem ( )
inline

Get the content of a location message (V2TIM_ELEM_TYPE_LOCATION)

◆ getFaceElem()

V2TIMFaceElem getFaceElem ( )
inline

Get the content of an emoji message (V2TIM_ELEM_TYPE_FACE)

◆ getMergerElem()

V2TIMMergerElem getMergerElem ( )
inline

Get the content of a forwarded message (V2TIM_ELEM_TYPE_MERGER)

◆ getGroupTipsElem()

V2TIMGroupTipsElem getGroupTipsElem ( )
inline

Get the content of a group tip message (V2TIM_ELEM_TYPE_GROUP_TIPS)

◆ getLocalCustomData()

String getLocalCustomData ( )
inline

Get custom message data. The data is saved locally and will not be sent. It will be lost after the app is reinstalled.

Returns

◆ setLocalCustomData()

void setLocalCustomData ( String  localCustomData)
inline

Set custom message data. The data is saved locally and will not be sent. It will be lost after the app is reinstalled.

Parameters
localCustomData

◆ getLocalCustomInt()

int getLocalCustomInt ( )
inline

Get custom message data. The data is saved locally and will not be sent. It will be lost after the app is reinstalled.

Returns

◆ setLocalCustomInt()

void setLocalCustomInt ( int  localCustomInt)
inline

Set custom message data, which can be used to mark whether a voice or video message is played. The data is saved locally will not be sent. It will be lost after the app is reinstalled.

Parameters
localCustomInt

◆ setCloudCustomData()

void setCloudCustomData ( String  data)
inline

Set cloud custom data. The data is saved in the cloud and will be sent. It can be pulled even after the app is reinstalled.

◆ getCloudCustomData()

String getCloudCustomData ( )
inline

Get cloud custom data

◆ isSelf()

boolean isSelf ( )
inline

Whether the message sender is the current user

◆ isRead()

boolean isRead ( )
inline

Whether the message has been read by the current user

◆ isPeerRead()

boolean isPeerRead ( )
inline

Whether the message was read by the other user(valid only for one-to-one messages). "true" will be returned if the message timestamp is equal to or smaller than the timestamp when the other user marked the message as read.

◆ isNeedReadReceipt()

boolean isNeedReadReceipt ( )
inline

Before using this function for group messages, you need to go to the Chat console to set the group types that support read receipts.

◆ setNeedReadReceipt()

void setNeedReadReceipt ( boolean  needReadReceipt)
inline

Set whether to enable read receipts

Attention

For group chats, read receipts are supported in 6.1 and later versions. You need to go to the Chat console to set the group types that support the feature first.

For one-to-one chats, the feature is supported in 6.2 and later versions.

The feature is only available in the Premium Edition.

◆ isBroadcastMessage()

boolean isBroadcastMessage ( )
inline

Whether the message is a broadcast message (supported only for AVChatRoom groups in Chat Premium v6.5 or later)

◆ getPriority()

int getPriority ( )
inline

Get the message priority

◆ getOfflinePushInfo()

V2TIMOfflinePushInfo getOfflinePushInfo ( )
inline

Get the offline push information

◆ getGroupAtUserList()

List<String> getGroupAtUserList ( )
inline

◆ getSeq()

long getSeq ( )
inline

Get the sequence number of the message

Message sequence numbers in group chats are generated in the cloud and are strictly incremented and unique within the group. Message sequence numbers in one-to-one chats are generated locally and are not necessarily strictly incremented or unique.

Returns

◆ getRandom()

long getRandom ( )
inline

Get the random number of the message

◆ isExcludedFromUnreadCount()

boolean isExcludedFromUnreadCount ( )
inline

Get whether the message is excluded from the conversation unread message count

Supported only in 5.3.425 and later versions.

Returns
true: excluded from the conversation unread message count; false: included in the conversation unread message count

◆ setExcludedFromUnreadCount()

void setExcludedFromUnreadCount ( boolean  excludedFromUnreadCount)
inline

Set whether to exclude the message from the unread message count. false (default): included in the unread message count; true: excluded from the unread message count

Supported only in 5.3.425 and later versions and not supported by meeting groups by default

◆ isExcludedFromLastMessage()

boolean isExcludedFromLastMessage ( )
inline

Get whether the message is not counted as the conversation's lastMessage

Supported only in 5.4.666 and later versions.

Returns
true: not counted as lastMessage; false: counted as lastMessage

◆ setExcludedFromLastMessage()

void setExcludedFromLastMessage ( boolean  excludedFromLastMessage)
inline

Set whether to skip the message when determining the conversation's lastMessage. false (default): do not skip; true: skip

Supported only in 5.4.666 and later versions.

◆ isExcludedFromContentModeration()

boolean isExcludedFromContentModeration ( )
inline

Get whether the current message is excluded from content moderation (cloud moderation).

Supported only in 7.1 and later versions.

Works only if cloud moderation is enabled.

Returns
true: excluded from content moderation; false: not excluded from content moderation.

◆ setExcludedFromContentModeration()

void setExcludedFromContentModeration ( boolean  excludedFromContentModeration)
inline

Set whether to exclude the current message from content moderation (cloud moderation). The default value is false.

Supported only in 7.1 and later versions.

Works only if cloud moderation is enabled.

◆ getCustomModerationConfigurationID()

String getCustomModerationConfigurationID ( )
inline

Get custom moderation configuration ID

◆ setCustomModerationConfigurationID()

void setCustomModerationConfigurationID ( String  customModerationConfigurationID)
inline

Set the custom moderation configuration ID (supported in 7.8 and later versions and valid only if cloud moderation is enabled). You can go to the console (On-cloud moderation -> Moderation configuration -> Custom configuration -> Add custom configuration) to get the configuration ID.

Attention
This field needs to be set before sending messages. It determines the moderation policy when messages are sent and will not be stored in cloud or locally.

◆ isSupportMessageExtension()

boolean isSupportMessageExtension ( )
inline

Get whether message extension is supported (supported only in 6.7 and later versions)

◆ setSupportMessageExtension()

void setSupportMessageExtension ( boolean  supportExtension)
inline

Set whether to enable message extension (supported only in Chat Premium 6.7 and later versions)

Attention

You need to configure message extension in the Chat console first. AVChatRoom groups do not support this feature.

You need to buy Premium Edition to use this feature.

◆ hasRiskContent()

boolean hasRiskContent ( )
inline

Whether the current message is identified as risk message (supported only in 7.4 and later versions)

Attention

This feature is only supported for voice and video messages.

This API works only if cloud moderation is enabled.

If a voice or video message sent is non-compliant, the onRecvMessageModified callback will be triggered, and the "hasRiskContent()" field in the callback message will be "true".

◆ getRevokerInfo()

V2TIMUserFullInfo getRevokerInfo ( )
inline

Get the recaller's info (supported only in 7.4 and later versions)

Returns
The recaller's info
Attention
Valid only for recalled messages

◆ getRevokeReason()

String getRevokeReason ( )
inline

Get the reason for recalling the message (supported only in 7.4 and later versions)

Returns
The reason for recalling the message
Attention
Valid only for recalled messages

◆ getPinnerInfo()

V2TIMGroupMemberFullInfo getPinnerInfo ( )
inline

Get pinner's info (supported only in imsdk 8.0 and later versions)

Returns
pinner's info
Attention
This field is only present in the pinned messages obtained through the GetPinnedGroupMessageList API.

◆ toString()

String toString ( )
inline

Field Documentation

◆ V2TIM_MSG_STATUS_SENDING

final int V2TIM_MSG_STATUS_SENDING = 1
static

Message being sent

◆ V2TIM_MSG_STATUS_SEND_SUCC

final int V2TIM_MSG_STATUS_SEND_SUCC = 2
static

Message sent successfully

◆ V2TIM_MSG_STATUS_SEND_FAIL

final int V2TIM_MSG_STATUS_SEND_FAIL = 3
static

Message fails to be sent

◆ V2TIM_MSG_STATUS_HAS_DELETED

final int V2TIM_MSG_STATUS_HAS_DELETED = 4
static

Message deleted

◆ V2TIM_MSG_STATUS_LOCAL_IMPORTED

final int V2TIM_MSG_STATUS_LOCAL_IMPORTED = 5
static

Message imported to local storage

◆ V2TIM_MSG_STATUS_LOCAL_REVOKED

final int V2TIM_MSG_STATUS_LOCAL_REVOKED = 6
static

Message recalled

◆ V2TIM_PRIORITY_DEFAULT

final int V2TIM_PRIORITY_DEFAULT = 0
static

Medium priority (default)

◆ V2TIM_PRIORITY_HIGH

final int V2TIM_PRIORITY_HIGH = 1
static

High priority, usually used for important messages such as gift messages

◆ V2TIM_PRIORITY_NORMAL

final int V2TIM_PRIORITY_NORMAL = 2
static

Medium priority, usually used for common messages

◆ V2TIM_PRIORITY_LOW

final int V2TIM_PRIORITY_LOW = 3
static

Low priority, usually used for like messages

◆ V2TIM_ELEM_TYPE_NONE

final int V2TIM_ELEM_TYPE_NONE = 0
static

No element

◆ V2TIM_ELEM_TYPE_TEXT

final int V2TIM_ELEM_TYPE_TEXT = 1
static

Text message

◆ V2TIM_ELEM_TYPE_CUSTOM

final int V2TIM_ELEM_TYPE_CUSTOM = 2
static

Custom message

◆ V2TIM_ELEM_TYPE_IMAGE

final int V2TIM_ELEM_TYPE_IMAGE = 3
static

Image message

◆ V2TIM_ELEM_TYPE_SOUND

final int V2TIM_ELEM_TYPE_SOUND = 4
static

Voice message

◆ V2TIM_ELEM_TYPE_VIDEO

final int V2TIM_ELEM_TYPE_VIDEO = 5
static

Video message

◆ V2TIM_ELEM_TYPE_FILE

final int V2TIM_ELEM_TYPE_FILE = 6
static

File message

◆ V2TIM_ELEM_TYPE_LOCATION

final int V2TIM_ELEM_TYPE_LOCATION = 7
static

Geographical location message

◆ V2TIM_ELEM_TYPE_FACE

final int V2TIM_ELEM_TYPE_FACE = 8
static

Emoji message

◆ V2TIM_ELEM_TYPE_GROUP_TIPS

final int V2TIM_ELEM_TYPE_GROUP_TIPS = 9
static

Group tip message (saved in the message list)

◆ V2TIM_ELEM_TYPE_MERGER

final int V2TIM_ELEM_TYPE_MERGER = 10
static

Forwarded message

◆ V2TIM_RECEIVE_MESSAGE

final int V2TIM_RECEIVE_MESSAGE = 0
static

Messages will be received when the user is online, and offline push notifications will be received when the user is offline

◆ V2TIM_NOT_RECEIVE_MESSAGE

final int V2TIM_NOT_RECEIVE_MESSAGE = 1
static

No message will be received

◆ V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE

final int V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE = 2
static

Messages will be received when the user is online, and no push notification will be received when the user is offline

◆ V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT

final int V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE_EXCEPT_AT = 3
static

Receive messages normally online, and only receive offline push of @ messages offline.

◆ V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ

final int V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ = 0
static

List of group members who have read the message

◆ V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD

final int V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_UNREAD = 1
static

List of group members who haven't read the message