TIMMsgRevoke

Introduction

Revoke message

Message revoking, please use stored message Json or search for message Json by message locator to avoid reconstruct message Json by yourself.

By default, senders can only revoke messages within 2 minutes after sending. You may loose or tight the time limit by Message recall settings

Message revoking needs UI's cooperation in both side. When sender revoked a message, the receiver receives TIMMsgRevokeCallbackFunc and it contains the message_locator_conv_id. You may use this to locate revoked message and change its UI to revoked status.

You can only revoke common messages in C2C or Group conversations. You cannot revoke messages that message_is_online_msg sets to true, which means message for online users only, and you can't revoke messages in AVChatRoom.

The receiver listens for a message recall notification through TIMSetMsgRevokeCallback.

Parameter details

Parameter name Parameter type Required Description
msgRevokeParams MsgRevokeParams yes Param of revoking message

Returned template

Promise<commonResult<string>>

{
    code: TIMResult | TIMErrCode;
    desc?: string | undefined;
    json_param?: string | undefined;
    json_params?: string | undefined; 
    user_data?: string | undefined;
}

Return value details

name type description
code TIMResultTIMErrCode Request result: Error codes. 0 means success.
desc string | undefined The description of the error. It will be empty if success.
json_param string | undefined Return value of calling API
json_params string | undefined Return value of calling API. Compatible field, which is returned in some cases.
user_data string | undefined ImSDK is responsible for transporting user-defined data without any processing

Code example

import TimRender from "im_electron_sdk/dist/renderer";
const timRenderInstance = new TimRender();
import { MsgRevokeParams,MsgGetMsgListParams,Json_value_msg } from "im_electron_sdk/dist/interfaces";
let convId = ''
let convType = 0

let param2:MsgGetMsgListParams = {
    conv_id:convId,
    conv_type: convType,
    params: {
        msg_getmsglist_param_last_msg: null,
        msg_getmsglist_param_count: 2,
        msg_getmsglist_param_is_ramble: true,
    },
    user_data: ""
}
let m = await timRenderInstance.TIMMsgGetMsgList(param2);
let json_msg_param:Json_value_msg = m.json_params[0];
let param: MsgRevokeParams = {
    conv_id: convId,    // required
    conv_type: convType,    // required
    json_msg_param: json_msg_param,     // required
    user_data: ''    // optional
}

const { code } = await timRenderInstance.TIMMsgRevoke(param);
if (code == 0) {
    // success
}

results matching ""

    No results matching ""