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
 
V2TIMGroupMemberInfo pinnerInfo
 
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 has been read by the current user.

◆ IsPeerRead()

bool IsPeerRead ( ) const

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.

◆ GetLocalCustomData()

V2TIMBuffer GetLocalCustomData ( ) const

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

◆ SetLocalCustomData()

void SetLocalCustomData ( const V2TIMBuffer localCustomData,
V2TIMCallback callback 
)

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

◆ GetLocalCustomInt()

int GetLocalCustomInt ( ) const

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

◆ SetLocalCustomInt()

void SetLocalCustomInt ( int  localCustomInt,
V2TIMCallback callback 
)

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.

◆ 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 friend information has not been pulled or the user is not a friend, null will be returned.

◆ nameCard

V2TIMString nameCard

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

◆ faceURL

V2TIMString faceURL

Sender's profile photo URL.

◆ groupID

V2TIMString groupID

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

◆ userID

V2TIMString userID

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.

◆ 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 are not necessarily strictly incremented or unique.

◆ random

uint64_t random

Random number of the message.

◆ status

Message sending status.

◆ supportMessageExtension

bool supportMessageExtension

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.

◆ isSelf

bool isSelf

Whether the message sender is the current user.

◆ needReadReceipt

bool needReadReceipt

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

bool isBroadcastMessage

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

◆ 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. The data is saved in the cloud and will be sent. It can be pulled even after the app is reinstalled.

◆ isExcludedFromUnreadCount

bool isExcludedFromUnreadCount

Set or get 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

bool isExcludedFromLastMessage

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

bool isExcludedFromContentModeration

Set whether to exclude the current message from content moderation (cloud moderation). The default value is false. Works only if cloud moderation is enabled. Supported only in 7.1 and later versions.

◆ customModerationConfigurationID

V2TIMString customModerationConfigurationID

Message 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.

◆ hasRiskContent

bool hasRiskContent

Whether the current message is identified as risk message (supported only in 7.4 and later versions) 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".

◆ offlinePushInfo

V2TIMOfflinePushInfo offlinePushInfo

Offline push information of the message.

◆ revokerInfo

V2TIMUserFullInfo revokerInfo

Get the recaller's info (supported only in 7.4 and later versions) Valid only for recalled messages

◆ revokeReason

V2TIMString revokeReason

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

◆ pinnerInfo

Pinner's info (supported only in imsdk 8.0 and later versions) This field is only present in the pinned messages obtained through the GetPinnedGroupMessageList API.

◆ obj_ptr

void* obj_ptr
inherited