TIMGroupInitGroupAttributes

Introduction

Init group attributes

Init group attributes, and will clear the previous attributes.

Support all group types except Community group.

The upper limit amount for attributes is 16, with the limit of 32 bytes for each attribute keys, and 4k for each values.

The total limit for attributes, including keys and values, is 16K.

NULL for json_keys to delete all group attributes.

TIMGroupInitGroupAttributes, TIMGroupSetGroupAttributes, TIMGroupDeleteGroupAttributes together share the limits of calling frequency 5 times per 10 seconds. Once exceeded, it returns 8511 error code and the limits loose to 5 times per second. Once exceeded again, it returns 10049 error code.

Except topics, group attributes support all group types

SDK limit of getGroupAttributes interface 20 times in 5 seconds

When modifying group attributes for the first time after each APP startup, please call getGroupAttributes to pull the latest group attributes before initiating the modification operation;

When multiple users modify the same group attribute at the same time, only the first user can execute it successfully, and other users will receive the 10056 error code; after receiving this error code, please call getGroupAttributes to update the locally saved group attributes to After updating, initiate the modification operation.

Parameter details

Parameter name Parameter type Required Description
initAttributesParams InitGroupAttributeParams yes Param of initializing group attributes

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 { InitGroupAttributeParams, GroupAttributes } from "im_electron_sdk/dist/interfaces";

let groupId = ''
let attributes: GroupAttributes = {
    group_attribute_key: '',    // required
    group_attribute_value: '',    // required
}

let param: InitGroupAttributeParams = {
    groupId: groupId,    // required
    attributes: [attributes],    // required
    data: ''    // optional
}
const { code } = await timRenderInstance.TIMGroupInitGroupAttributes(param)
if (code == 0) {
    // success
}

results matching ""

    No results matching ""