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.

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 Description
message V2TimMessage yes The modified message.

Returned template

V2TimValueCallback<V2TimMessageChangeInfo>

{
    code : number
    desc : string
    data : {
      code : number
      desc : string
      message : V2TimMessage
    }
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.
data V2TimMessageChangeInfo The modified message.

Code example

import { TencentImSDKPlugin } from 'react-native-tim-js';


const msgListRes = await TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .findMessages(['msgid']);

if (msgListRes.code === 0) {
    const messageList = msgListRes.data;
    if (messageList!.length !== 0) {
        const originMessage = messageList![0];
        originMessage.cloudCustomData = 'change data';
        const modifyMessageRes = await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .modifyMessage(originMessage);
        if (modifyMessageRes.code === 0) {
            if (modifyMessageRes.data?.code === 0) {

            }
        }
    }
}

results matching ""

    No results matching ""