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

Detailed Description

Definition of V2TIMMessage.

Public Member Functions

bool IsRead () const
 
bool IsPeerRead () const
 
V2TIMBuffer GetLocalCustomData () const
 
void SetLocalCustomData (const V2TIMBuffer &localCustomData, V2TIMCallback *callback)
 
int GetLocalCustomInt () const
 
void SetLocalCustomInt (int localCustomInt, V2TIMCallback *callback)
 
 V2TIMMessage ()
 
 V2TIMMessage (const V2TIMMessage &)
 
V2TIMMessageoperator= (const V2TIMMessage &)
 
 ~V2TIMMessage () override
 

Data Fields

V2TIMString msgID
 
int64_t timestamp
 
V2TIMString sender
 
V2TIMString nickName
 
V2TIMString friendRemark
 
V2TIMString nameCard
 
V2TIMString faceURL
 
V2TIMString groupID
 
V2TIMString userID
 
uint64_t seq
 
uint64_t random
 
V2TIMMessageStatus status
 
bool supportMessageExtension
 
bool isSelf
 
bool needReadReceipt
 
bool isBroadcastMessage
 
V2TIMMessagePriority priority
 
V2TIMStringVector groupAtUserList
 
V2TIMElemVector elemList
 
V2TIMBuffer cloudCustomData
 
bool isExcludedFromUnreadCount
 
bool isExcludedFromLastMessage
 
bool isExcludedFromContentModeration
 
V2TIMString customModerationConfigurationID
 
bool hasRiskContent
 
V2TIMOfflinePushInfo offlinePushInfo
 
V2TIMUserFullInfo revokerInfo
 
V2TIMString revokeReason
 
void * obj_ptr
 

Constructor & Destructor Documentation

◆ V2TIMMessage() [1/2]

◆ V2TIMMessage() [2/2]

V2TIMMessage ( const V2TIMMessage )

◆ ~V2TIMMessage()

~V2TIMMessage ( )
override

Member Function Documentation

◆ IsRead()

bool IsRead ( ) const

Whether the message is read by the current user.

◆ IsPeerRead()

bool IsPeerRead ( ) const

Whether the message is read by the peer party (valid only for one-to-one messages) The condition for this field to be true is that the message timestamp <= the time when the peer marked conversation as read

◆ GetLocalCustomData()

V2TIMBuffer GetLocalCustomData ( ) const

Get local custom message data (saved locally, will not be sent to the peer end, and will become invalid after the app is uninstalled and reinstalled)

◆ SetLocalCustomData()

void SetLocalCustomData ( const V2TIMBuffer localCustomData,
V2TIMCallback callback 
)

Set local custom message data (saved locally, will not be sent to the peer end, and will become invalid after the app is uninstalled and reinstalled)

◆ GetLocalCustomInt()

int GetLocalCustomInt ( ) const

Get local custom message data (saved locally, will not be sent to the peer end, and will become invalid after the app is uninstalled and reinstalled)

◆ SetLocalCustomInt()

void SetLocalCustomInt ( int  localCustomInt,
V2TIMCallback callback 
)

Set local custom message data (saved locally, will not be sent to the peer end, and will become invalid after the app is uninstalled and reinstalled)

◆ operator=()

V2TIMMessage& operator= ( const V2TIMMessage )

Field Documentation

◆ msgID

V2TIMString msgID

Message ID.

◆ timestamp

int64_t timestamp

UTC timestamp of the message.

◆ sender

V2TIMString sender

Sender's userID.

◆ nickName

V2TIMString nickName

Sender's nickname.

◆ friendRemark

V2TIMString friendRemark

Sender's friend remark. If you have not pulled the friend information or are not a friend, nil is returned.

◆ nameCard

V2TIMString nameCard

For a group message, nameCard is the group name card of the sender.

◆ faceURL

V2TIMString faceURL

Sender's profile photo URL.

◆ groupID

V2TIMString groupID

For a group message, groupID is the message receiving group ID. Otherwise, groupID is null.

◆ userID

V2TIMString userID

For a one-to-one message, userID is the conversation user ID. Otherwise, userID is null. Suppose you are chatting with userA, regardless of whether it is a message sent to userA by yourself or a message sent to yourself by userA, the userID here is userA.

◆ seq

uint64_t seq

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 cannot be guaranteed to be strictly incremented and unique.

◆ random

uint64_t random

Random number of the message.

◆ status

Message sending status.

◆ supportMessageExtension

bool supportMessageExtension

Whether to support message extension (supported only in 6.7 and later versions)

Attention

AVChatRoom message do not support this feature.

You need to go to the IM console to enable this feature.

You need to buy Premium Edition to use this feature.

◆ isSelf

bool isSelf

Whether the message sender is the current user.

◆ needReadReceipt

bool needReadReceipt

Whether a read receipt is required

Attention

This feature for group chats is supported in 6.1 and later version. And you need to go to the IM console to enable this feature for specific group type.

This feature for one-to-one chats is supported in 6.2 and later version.

You need to buy Premium Edition to use this feature for both group and one-to-one chats.

◆ isBroadcastMessage

bool isBroadcastMessage

Whether the message is a kind of broadcast message Only supported in AVChatRoom Only supported in 6.5 and later versions and need to buy Premium Edition

◆ priority

Message priority (only V2TIMMessage received by onRecvNewMessage is valid)

◆ groupAtUserList

V2TIMStringVector groupAtUserList

UserID list of users who has been @ in the group message.

◆ elemList

V2TIMElemVector elemList

V2TIMElem list

It is recommended to store only one elem in a message. When receiving this message, call elemList[0] to get this elem. The sample code is as follows: if (1 == message.elemList.Size()) { V2TIMElem *elem = message.elemList[0]; switch (elem->elemType) { case V2TIM_ELEM_TYPE_TEXT: V2TIMTextElem *textElem = static_cast<V2TIMTextElem *>(elem); break; case V2TIM_ELEM_TYPE_CUSTOM: V2TIMCustomElem *customElem = static_cast<V2TIMCustomElem *>(elem); break; case V2TIM_ELEM_TYPE_FACE: V2TIMFaceElem *faceElem = static_cast<V2TIMFaceElem *>(elem); break; case V2TIM_ELEM_TYPE_LOCATION: V2TIMLocationElem *locationElem = static_cast<V2TIMLocationElem *>(elem); break; default: break; } }

If a message has multiple elems, traverse the elemList list to get all elem elements,the sample code is as follows: for (size_t i = 0; i < message.elemList.Size(); ++i) { V2TIMElem *elem = message.elemList[i]; switch (elem->elemType) { case V2TIM_ELEM_TYPE_TEXT: V2TIMTextElem *textElem = static_cast<V2TIMTextElem *>(elem); break; case V2TIM_ELEM_TYPE_CUSTOM: V2TIMCustomElem *customElem = static_cast<V2TIMCustomElem *>(elem); break; case V2TIM_ELEM_TYPE_FACE: V2TIMFaceElem *faceElem = static_cast<V2TIMFaceElem *>(elem); break; case V2TIM_ELEM_TYPE_LOCATION: V2TIMLocationElem *locationElem = static_cast<V2TIMLocationElem *>(elem); break; default: break; } }

If your message requires multiple elems, you can call elemList.PushBack to add a new elem after creating the Message object. Here is the sample code to create a message object with two elements. V2TIMCustomElem *customElem = new V2TIMCustomElem(); customElem->data = buffer; V2TIMMessage message = messageManager.CreateTextMessage("text"); message.elemList.PushBack(customElem);

◆ cloudCustomData

V2TIMBuffer cloudCustomData

Cloud custom data (saved in the cloud, will be sent to the peer end, and can still be pulled after the app is uninstalled and reinstalled)

◆ isExcludedFromUnreadCount

bool isExcludedFromUnreadCount

Whether the message is excluded from the conversation unread message count. false (default): included in the unread message count of the conversation; true: excluded from the conversation unread message count

Supported only in 5.3.425 and later versions. Meeting group does not support this field by default.

◆ isExcludedFromLastMessage

bool isExcludedFromLastMessage

Whether the message is excluded from the conversation lastMessage. false (default): included in the conversation lastMessage; true: excluded from the conversation lastMessage Supported only in 5.4.666 and later versions.

◆ isExcludedFromContentModeration

bool isExcludedFromContentModeration

Specify Whether the current message will be excluded from content moderation (including [Local moderation] and [Cloud moderation]). Its default value is false. Valid only after the [Local Moderation] or [Cloud Moderation] function is activated. [Local moderation] please refer to document local moderation function. [Cloud moderation] please refer to document cloud moderation function Supported only in 7.1 and later versions.

◆ customModerationConfigurationID

V2TIMString customModerationConfigurationID

Message custom moderation configuration (supported only in 7.8 and later versions) Valid only after the [Cloud Moderation] function is activated. You can go to the Console (Cloud moderation -> Moderation configuration -> Custom configuration -> Add custom configuration) to get the configuration ID. [Custom moderation] please refer to document cloud moderation function

Attention
This field needs to be set up before sending messages. It is only used to control the the message moderation when sending messages, Its value will not be stored in cloud and local.

◆ hasRiskContent

bool hasRiskContent

Whether the current message is identified as risk message (supported only in 7.4 and later versions) Only messages containing sound and video are supported. It will take effect after you enabling the [Cloud Moderation] feature, [Cloud Moderation] please refer to document cloud moderation function. If you send a risky sound or video message, you will receive the onRecvMessageModified callback with this field being set to true after the cloud moderation.

◆ offlinePushInfo

V2TIMOfflinePushInfo offlinePushInfo

Offline push information of the message.

◆ revokerInfo

V2TIMUserFullInfo revokerInfo

Revoker's info (supported only in imsdk 7.4 and later versions) Valid only for revoked message

◆ revokeReason

V2TIMString revokeReason

Revoke reason (supported only in imsdk 7.4 and later versions) Valid only for revoked message

◆ obj_ptr

void* obj_ptr
inherited