modifyMessage

Introduction

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.

Works since version 4.0.1.

A conversation participant can call the modifyMessage API (dart) to modify a sent message in the conversation.

The IM 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.

You can use this functions to build voting, electing, message reaction and other functions related to the interactions.

Currently, the following information of a message can be modified:

  1. localCustomData

  2. localCustomInt

  3. cloudCustomData

  4. V2TIMTextElem

  5. V2TIMCustomElem

For details, you can referring to this document.

Parameter details

Parameter name Parameter type Required Platform Description
message V2TimMessage yes All The modified message.

Returned template

V2TimValueCallback<V2TimMessageChangeInfo>

{
    code : int
    desc : String
    data : {
      code : int
      desc : String
      message : V2TimMessage
    }
}

Return value details

name type description
code int Request result: Error codes. 0 means success.
desc String The description of the failure.
data V2TimMessageChangeInfo The modified message.

Code example

    V2TimValueCallback<List<V2TimMessage>> msgListRes = await TencentImSDKPlugin
        .v2TIMManager
        .getMessageManager()
        .findMessages(messageIDList: ['msgid']); 
    if (msgListRes.code == 0) {
      List<V2TimMessage>? messageList = msgListRes.data;
      if (messageList!.isNotEmpty) {
        V2TimMessage originMessage = messageList[0];
        originMessage.cloudCustomData = "change data"; 
        V2TimValueCallback<V2TimMessageChangeInfo> modifyMessageRes =
            await TencentImSDKPlugin.v2TIMManager
                .getMessageManager()
                .modifyMessage(message: originMessage);
        if (modifyMessageRes.code == 0) {
          if (modifyMessageRes.data?.code == 0) {
          }
        }
      }
    }

results matching ""

    No results matching ""