메시지 수정
Overview
This feature enables any member in a conversation to modify a successfully sent message in the conversation. The message will be synced to all the members in the conversation once modified successfully.
Modifying a Message
A conversation participant can call the
modifyMessage
API (details) to modify a sent message in the conversation.
The Chat SDK allows any conversation participant to modify a message in the conversation. You can add more restrictions at the business layer, for example, only allowing the message sender to modify the message.Currently, the following information of a message can be modified:
localCustomData
(details)localCustomInt
(details)cloudCustomData
(details)V2TIMTextElem
(details)V2TIMCustomElem
(details)Sample code:
// Find the message to be modifiedconst msgListRes = await TencentImSDKPlugin.v2TIMManager.getMessageManager().findMessages(["msgid"]);// Edit the messageif (msgListRes.code == 0) {const messageList = msgListRes.data;if (messageList.isNotEmpty) {const originMessage = messageList[0];originMessage.cloudCustomData = "change data";const modify = await TencentImSDKPlugin.v2TIMManager.getMessageManager().modifyMessage(originMessage);if (modify.code == 0) {if (modify.data.code == 0) {// Modified successfully}}}}
Listening for a Message Modification Callback
Conversation participants call
addAdvancedMsgListener
(details) to add the advanced message listener.After a message in the conversation is modified, all the participants will receive the
onRecvMessageModified
callback (details), which contains the modified message object.Sample code:
onRecvMessageModified: (message) => {// `msg` is the modified message object};