The group manager class, which defines how to manage groups, like group creation and destruction and member management.

Hierarchy

  • BaseManager
    • ChatGroupManager

Constructors

Properties

_eventEmitter?: NativeEventEmitter
TAG: string = 'ChatGroupManager'

Methods

  • Accepts a group invitation.

    Parameters

    • groupId: string

      The group ID.

    • inviter: string

      The user ID of the inviter.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Accepts a join request.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • userId: string

      The ID of the user who sends a request to join the group.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Adds a group admin.

    Only the group owner can call this method and group admins cannot.

    Parameters

    • groupId: string

      The group ID.

    • admin: string

      The user ID of the admin to add.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Adds members to the allow list of the group.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The user IDs of members to be added to the allow list of the group.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Adds a group listener.

    Parameters

    Returns void

  • Adds users to the group.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of new members to add.

    • Optionalwelcome: string

      (optional) The welcome message.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Blocks group messages.

    The user that blocks group messages is still a group member, but cannot receive group messages.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Adds the user to the block list of the group.

    Users will be first removed from the group they have joined before being added to the block list of the group. The users on the group block list cannot join the group again.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of user IDs of members to be added to the block list.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Modifies the group description.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • description: string

      The new group description.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Changes the group name.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • groupName: string

      The new group name.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Transfers the group ownership.

    Only the group owner can call this method.

    Parameters

    • groupId: string

      The group ID.

    • newOwner: string

      The user ID of the new group owner.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Creates a group instance.

    After the group is created, the data in the memory and database will be updated and multiple devices will receive the notification event and update the group to the memory and database.

    You can set ChatGroupEventListener to listen for the event.

    Parameters

    • options: ChatGroupOptions

      The options for creating a group. They are optional and cannot be null. See ChatGroupOptions. The options are as follows:

      • The maximum number of members allowed in the group. The default value is 200.
      • The group style. See ChatGroupStyle. The default value is ChatGroupStyle.PrivateOnlyOwnerInvite.
      • Whether to ask for permission when inviting a user to join the group. The default value is false, indicating that invitees are automatically added to the group without their permission.
      • The extension of group details.
    • groupName: string

      The group name. It is optional. Pass null if you do not want to set this parameter.

    • Optionaldesc: string

      The group description. It is optional. Pass null if you do not want to set this parameter.

    • OptionalinviteMembers: string[]

      The group member array. The group owner ID is optional. This parameter cannot be null.

    • OptionalinviteReason: string

      The group joining invitation. It is optional. Pass null if you do not want to set this parameter.

    Returns Promise<ChatGroup>

    The created group instance.

    A description of the exception. See ChatError.

  • Declines a group invitation.

    Parameters

    • groupId: string

      The group ID.

    • inviter: string

      The user ID of the inviter.

    • Optionalreason: string

      The reason for declining the invitation.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Declines a join request.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • username: string

      The ID of the user who sends a request to join the group.

    • Optionalreason: string

      The reason of declining the join request.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Destroys the group instance.

    Only the group owner can call this method.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Downloads the shared file of the group.

    Parameters

    • groupId: string

      The group ID.

    • fileId: string

      The ID of the shared file.

    • savePath: string

      The local path of the shared file.

    • Optionalcallback: ChatGroupFileStatusCallback

      (Optional) The file upload result callback.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Uses the pagination to get the allow list of the group from the server.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<string[]>

    The allow list of the group.

    A description of the exception. See ChatError.

  • Gets the group announcement from the server.

    All group members can call this method.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<string>

    The group announcement.

    A description of the exception. See ChatError.

  • Uses the pagination to get the group block list from the server.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • pageSize: number = 200

      The number of group members on the block list that you expect to get on each page.

    • pageNum: number = 1

      The page number, starting from 1.

    Returns Promise<string[]>

    The group block list.

    A description of the exception. See ChatError.

  • Uses the pagination to get the shared files of the group from the server.

    Parameters

    • groupId: string

      The group ID.

    • pageSize: number = 200

      The number of shared files that you get on each page.

    • pageNum: number = 1

      The page number, starting from 1.

    Returns Promise<ChatGroupSharedFile[]>

    The shared file list.

    A description of the exception. See ChatError.

  • Gets the group information from the server.

    Parameters

    • groupId: string

      The group ID.

    • isFetchMembers: boolean = false

      Whether to get group member information: - true: Yes. This method can return information of at most 200 group members. To get information of all group members, you can call fetchMemberListFromServer. - false: No.

    Returns Promise<undefined | ChatGroup>

    The group instance. The SDK returns undefined if the group does not exist.

    A description of the exception. See ChatError.

  • Gets the number of groups joined by the current user.

    Returns Promise<number>

    The list of joined groups of the current user.

    A description of the exception. See ChatError.

  • Gets the list of groups that the current user has joined.

    This method gets data from the server.

    This method returns a group list which does not contain member information. If you want to update information of a group to include its member information, call fetchMemberListFromServer.

    Parameters

    • pageSize: number

      The number of groups that you expect to return on each page [1, 20].

    • pageNum: number

      The page number, starting from 0.

    Returns Promise<ChatGroup[]>

    The list of groups that the current user joins.

    A description of the exception. See ChatError.

  • Gets all custom attributes of a group member.

    Parameters

    • groupId: string

      The group ID.

    • member: string

      The user ID of the group member whose all custom attributes are retrieved.

    Returns Promise<undefined | Record<string, string>>

    The user attributes.

    A description of the exception. See ChatError.

  • Uses the pagination to get the member list of the group from the server.

    Parameters

    • groupId: string

      The group ID.

    • pageSize: number = 200

      The number of group members that you expect to get on each page.

    • Optionalcursor: string

      The cursor position from which to start to get data. At the first method call, if you set cursor as null, the SDK gets the data in the reverse chronological order of when users join the group.

    Returns Promise<ChatCursorResult<string>>

    The group member list and the cursor for the next query. See ChatCursorResult.

    A description of the exception. See ChatError.

  • Gets custom attributes of multiple group members by attribute key.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of user IDs of group members whose custom attributes are retrieved.(limitation is ten. More than callback error. )

    • OptionalattributeKeys: string[]

      The array of keys of custom attributes to be retrieved.

    Returns Promise<Map<string, Record<string, string>>>

    The users attributes.

    A description of the exception. See ChatError.

  • Uses the pagination to get the mute list of the group from the server.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • pageSize: number = 200

      The number of muted members that you expect to get on each page.

    • pageNum: number = 1

      The page number, starting from 1.

    Returns Promise<string[]>

    The group mute list.

    A description of the exception. See ChatError.

  • Gets public groups from the server with pagination.

    Parameters

    • pageSize: number

      The number of public groups that you expect on each page.

    • Optionalcursor: string

      The cursor position from which to start to get data. At the first method call, if you set cursor as null, the SDK gets the data in the reverse chronological order of when groups are created.

    Returns Promise<ChatCursorResult<ChatGroupInfo>>

    The group list and the cursor for the next query. See ChatCursorResult.

    A description of the exception. See ChatError.

  • Gets the group instance from the memory by group ID.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<undefined | ChatGroup>

    The group instance. The SDK returns undefined if the group does not exist.

    A description of the exception. See ChatError.

  • Gets the list of groups that the current user has joined.

    This method gets data from the local database.

    Returns Promise<ChatGroup[]>

    The group list.

    A description of the exception. See ChatError.

  • Invites users to join the group.

    This method works only for groups with the following styles:

    • PrivateOnlyOwnerInvite style: Only the group owner can invite users to join the group.
    • PrivateMemberCanInvite style: Each group member can invite users to join the group.
    • PublicJoinNeedApproval style: Each group member can invite users to join the group and users can join a group only after getting approval from the group owner or admins.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of user IDs of new members to invite.

    • Optionalreason: string

      The invitation reason.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Gets whether the member is on the allow list of the group.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<boolean>

    Whether the current user is on the allow list of the group.

    • true: Yes.
    • false: No.

    A description of the exception. See ChatError.

  • Joins a public group.

    For a group that requires no authentication,users can join it freely without obtaining permissions from the group owner or admin.

    For a group that requires authentication, users need to wait for the group owner or admin to agree before joining the group. For details, see ChatGroupStyle.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Leaves a group.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Mutes all members.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Mutes group members.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The list of user IDs of members to mute.

    • duration: number = -1

      The mute duration in milliseconds. It is a reserved parameter.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes a group admin.

    Only the group owner can call this method.

    Parameters

    • groupId: string

      The group ID.

    • admin: string

      The user ID of the group admin to remove.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Clears all group listeners.

    Returns void

  • Removes members from the allow list of the group.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The user IDs of members to be removed from the allow list of the group.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes the group listener.

    Parameters

    Returns void

  • Removes a shared file of the group.

    Group members can delete their own uploaded files. The group owner or admin can delete all shared files.

    Parameters

    • groupId: string

      The group ID.

    • fileId: string

      The ID of the shared file.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes a member from the group.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The user ID of the member to be removed.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Requests to join a group.

    You can call this method to only join public groups requiring authentication, i.e., groups with the style of ChatGroupStyle.PublicJoinNeedApproval.

    Parameters

    • groupId: string

      The group ID.

    • Optionalreason: string

      The reason for requesting to join the group.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Sets custom attributes of a group member.

    Parameters

    • groupId: string

      The group ID.

    • member: string

      The array of user IDs of group members whose custom attributes are retrieved.(limitation is ten. More than callback error. )

    • attributes: Record<string, string>

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Parameters

    • event: NativeEventEmitter

    Returns void

  • Unblocks group messages.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes users from the group block list.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The user IDs of members to be removed from the group block list.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Unmutes all group members.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Unmutes group members.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of user IDs of members to be unmuted.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Updates the group announcement.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • announcement: string

      The group announcement.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Updates the group extension field.

    Only the group owner or admin can call this method.

    Parameters

    • groupId: string

      The group ID.

    • extension: string

      The updated group extension field.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Uploads the shared file to the group.

    When a shared file is uploaded, the upload progress callback will be triggered.

    Parameters

    • groupId: string

      The group ID.

    • filePath: string

      The local path of the shared file.

    • Optionalcallback: ChatGroupFileStatusCallback

      (Optional) The file upload result callback.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Type Parameters

    • T

    Parameters

    • method: string
    • Optionalargs: {}

      Returns Promise<T>

    • Parameters

      • result: any

      Returns void

    • Parameters

      Returns void

    • Parameters

      Returns void