TIMMsgSetMessageExtensions

Introduction

Set message extension

This method only works with Ultimate Edition

Usage limitation: 1. the message_support_message_extension should be set to true before the message was sent; 2. the message must be sent successfully; 3. The message couldn't be from the Community or the AVChatRoom.

If the extension key already exists, the extended value information will be modified. If the extension key does not exist, an extension will be added.

The maximum length of the extended key is 100 bytes, the maximum length of the extended value is 1KB.

Up to 20 extensions can be set once.

A message could be set with 300 extensions.

When multiple users set the same extended key at the same time, only the first user could set it successfully. The other users would receive the 23001 error code and the updated information. After receiving the error code and the latest information, please re set it as required.

We strongly suggest that different users set different extension key, so that most of the scenes won't conflict, such as voting, and investigation. You can use userID as the extension key.

Parameter details

Parameter name Parameter type Required Description
msgSetMessageExtensionsParam TIMMsgSetMessageExtensionsParam yes Param of setting message extension

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

TIMMsgSetMessageExtensions: async () => {
  var message = await advanceMessageManager.TIMMsgGetMsgList(null);
  let m = message.json_params[1];

  m.message_support_message_extension = true;
  let param: TIMMsgSetMessageExtensionsParam = {
    json_msg: m,
    json_extension_array: [{
      message_extension_key: "key",
      message_extension_value: "value"
    }],
    user_data: ""
  }
  return timRenderInstance.TIMMsgSetMessageExtensions(param);
}

results matching ""

    No results matching ""