TIMGroupCreate

Introduction

Create group

To group friends into categories such as "Classmates at university" and "Coworkers", call the following APIs.

You can specify groupID when creating a new group. And IM SDK may assign and groupID for you in case you don't specify one, and it is transmitted to you by the callback.

You cannot create duplicated groups in one SDKAppID.

Set create_group_param_group_member_array to initialize group members (NULL for AVChatRoom).

To create Community, you need to buy Ultimate Package and apply for Community.

For SDKAppID in Professional/Ultimate packages, the maximum net increase in group count per day (the number of created groups minus the number of disbanded groups) is 10,000 for all group types. the free peak group count is 100,000 per month, and you will need to pay fees for exceeding the quota in a plan. It is recommend that you disband the groups that are no longer needed in a timely manner.

Parameter details

Parameter name Parameter type Required Description
createGroupParams CreateGroupParams yes Param of creating group

Returned template

Promise<commonResult<GroupParams>>

{
    code: TIMResult | TIMErrCode;
    desc?: string | undefined;
    json_param?: GroupParams | undefined;
    json_params?: GroupParams | 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 GroupParams | undefined Return value of calling API
json_params GroupParams | 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 { GroupParams, CreateGroupParams, GroupInfoCustemString, GroupMemberInfo, GroupMemberInfoCustemString } from "im_electron_sdk/dist/interfaces";

let custom_info: GroupInfoCustemString = {
    group_info_custom_string_info_key: '',// required
    group_info_custom_string_info_value: ''// required
}

let member_custom_info: GroupMemberInfoCustemString = {
    group_member_info_custom_string_info_key: '',// required
    group_member_info_custom_string_info_value: '',// required
}

let member_info: GroupMemberInfo = {
    group_member_info_identifier: '',   // required
    group_member_info_join_time: 0,// optional
    group_member_info_member_role: 0,// optional,参考[TIMGroupMemberRole]
    group_member_info_msg_flag: 0,// optional
    group_member_info_msg_seq: 0,// optional
    group_member_info_shutup_time: 0,// optional
    group_member_info_name_card: '',// optional
    group_member_info_custom_info: [member_custom_info]// optional
}

let group_param: GroupParams = {
    create_group_param_add_option: 0,// optional
    create_group_param_group_name: '',  // required
    create_group_param_group_type: 0,// optional
    create_group_param_custom_info: [custom_info],// optional
    create_group_param_face_url: '',// optional
    create_group_param_group_member_array: [member_info],// optional
    create_group_param_introduction: '',// optional
    create_group_param_notification: ''// optional
}

let param: CreateGroupParams = {
    params: group_param,
    data: ""
}
let { code } = await timRenderInstance.TIMGroupCreate(param);

if (code == 0) {
    // success
}

results matching ""

    No results matching ""