Options
All
  • Public
  • Public/Protected
  • All
Menu

export manager

Hierarchy

  • BaseManager
    • ChatGroupManager

Index

Constructors

Properties

_eventEmitter?: NativeEventEmitter
_groupListeners: Set<ChatGroupEventListener>
_groupSubscriptions: Map<string, EmitterSubscription>
TAG: string = 'ChatGroupManager'

Methods

  • acceptInvitation(groupId: string, inviter: string): Promise<void>
  • Accepts a group invitation.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • inviter: string

      The user ID of the inviter.

    Returns Promise<void>

  • acceptJoinApplication(groupId: string, userId: string): Promise<void>
  • Accepts a join request.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • userId: string

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

    Returns Promise<void>

  • addAdmin(groupId: string, admin: string): Promise<void>
  • Adds a group admin.

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

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • admin: string

      The user ID of the admin to add.

    Returns Promise<void>

  • addAllowList(groupId: string, members: string[]): Promise<void>
  • Adds members to the allow list of the group.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    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>

  • addMembers(groupId: string, members: string[], welcome?: string): Promise<void>
  • Adds users to the group.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of new members to add.

    • Optional welcome: string

      (optional) The welcome message.

    Returns Promise<void>

  • blockGroup(groupId: string): Promise<void>
  • Blocks group messages.

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

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • blockMembers(groupId: string, members: string[]): Promise<void>
  • 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.

    throws

    A description of the exception. See ChatError.

    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>

  • changeGroupDescription(groupId: string, description: string): Promise<void>
  • Modifies the group description.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • description: string

      The new group description.

    Returns Promise<void>

  • changeGroupName(groupId: string, groupName: string): Promise<void>
  • Changes the group name.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • groupName: string

      The new group name.

    Returns Promise<void>

  • changeOwner(groupId: string, newOwner: string): Promise<void>
  • Transfers the group ownership.

    Only the group owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • newOwner: string

      The user ID of the new group owner.

    Returns Promise<void>

  • createGroup(options: ChatGroupOptions, groupName: string, desc?: string, inviteMembers?: string[], inviteReason?: string): Promise<ChatGroup>
  • 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.

    throws

    A description of the exception. See ChatError.

    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.

    • Optional desc: string

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

    • Optional inviteMembers: string[]

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

    • Optional inviteReason: 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.

  • declineInvitation(groupId: string, inviter: string, reason?: string): Promise<void>
  • Declines a group invitation.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • inviter: string

      The user ID of the inviter.

    • Optional reason: string

      The reason for declining the invitation.

    Returns Promise<void>

  • declineJoinApplication(groupId: string, username: string, reason?: string): Promise<void>
  • Declines a join request.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • username: string

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

    • Optional reason: string

      The reason of declining the join request.

    Returns Promise<void>

  • destroyGroup(groupId: string): Promise<void>
  • Destroys the group instance.

    Only the group owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • Downloads the shared file of the group.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • fileId: string

      The ID of the shared file.

    • savePath: string

      The local path of the shared file.

    • Optional callback: ChatGroupFileStatusCallback

      (Optional) The file upload result callback.

    Returns Promise<void>

  • fetchAllowListFromServer(groupId: string): Promise<string[]>
  • Uses the pagination to get the allow list of the group from the server.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<string[]>

    The allow list of the group.

  • fetchAnnouncementFromServer(groupId: string): Promise<string>
  • Gets the group announcement from the server.

    All group members can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<string>

    The group announcement.

  • fetchBlockListFromServer(groupId: string, pageSize?: number, pageNum?: number): Promise<string[]>
  • Uses the pagination to get the group block list from the server.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    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.

  • fetchGroupFileListFromServer(groupId: string, pageSize?: number, pageNum?: number): Promise<ChatGroupSharedFile[]>
  • Uses the pagination to get the shared files of the group from the server.

    throws

    A description of the exception. See ChatError.

    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.

  • fetchGroupInfoFromServer(groupId: string, isFetchMembers?: boolean): Promise<undefined | ChatGroup>
  • Gets the group information from the server.

    throws

    A description of the exception. See ChatError.

    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.

  • fetchJoinedGroupsFromServer(pageSize: number, pageNum: number): Promise<ChatGroup[]>
  • 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.

    throws

    A description of the exception. See ChatError.

    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.

  • fetchMemberAttributes(groupId: string, member: string): Promise<undefined | Record<string, string>>
  • Gets all custom attributes of a group member.

    throws

    A description of the exception. See ChatError.

    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.

  • fetchMemberListFromServer(groupId: string, pageSize?: number, cursor?: string): Promise<ChatCursorResult<string>>
  • Uses the pagination to get the member list of the group from the server.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • pageSize: number = 200

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

    • Optional cursor: 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.

  • fetchMembersAttributes(groupId: string, members: string[], attributeKeys?: string[]): Promise<Map<string, Record<string, string>>>
  • Gets custom attributes of multiple group members by attribute key.

    throws

    A description of the exception. See ChatError.

    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. )

    • Optional attributeKeys: string[]

      The array of keys of custom attributes to be retrieved.

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

    The users attributes.

  • fetchMuteListFromServer(groupId: string, pageSize?: number, pageNum?: number): Promise<string[]>
  • Uses the pagination to get the mute list of the group from the server.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    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.

  • Gets public groups from the server with pagination.

    throws

    A description of the exception. See ChatError.

    Parameters

    • pageSize: number

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

    • Optional cursor: 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.

  • getGroupWithId(groupId: string): Promise<undefined | ChatGroup>
  • Gets the group instance from the memory by group ID.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<undefined | ChatGroup>

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

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

    This method gets data from the local database.

    throws

    A description of the exception. See ChatError.

    Returns Promise<ChatGroup[]>

    The group list.

  • inviteUser(groupId: string, members: string[], reason?: string): Promise<void>
  • 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.
    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of user IDs of new members to invite.

    • Optional reason: string

      The invitation reason.

    Returns Promise<void>

  • invokeGroupListener(params: any): void
  • Parameters

    • params: any

    Returns void

  • isMemberInAllowListFromServer(groupId: string): Promise<boolean>
  • Gets whether the member is on the allow list of the group.

    throws

    A description of the exception. See ChatError.

    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.
  • joinPublicGroup(groupId: string): Promise<void>
  • 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.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • leaveGroup(groupId: string): Promise<void>
  • Leaves a group.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • muteAllMembers(groupId: string): Promise<void>
  • Mutes all members.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • muteMembers(groupId: string, members: string[], duration?: number): Promise<void>
  • Mutes group members.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    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>

  • removeAdmin(groupId: string, admin: string): Promise<void>
  • Removes a group admin.

    Only the group owner can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • admin: string

      The user ID of the group admin to remove.

    Returns Promise<void>

  • removeAllGroupListener(): void
  • Clears all group listeners.

    Returns void

  • removeAllowList(groupId: string, members: string[]): Promise<void>
  • Removes members from the allow list of the group.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    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>

  • Removes the group listener.

    Parameters

    Returns void

  • removeGroupSharedFile(groupId: string, fileId: string): Promise<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.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • fileId: string

      The ID of the shared file.

    Returns Promise<void>

  • removeMembers(groupId: string, members: string[]): Promise<void>
  • Removes a member from the group.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The user ID of the member to be removed.

    Returns Promise<void>

  • requestToJoinPublicGroup(groupId: string, reason?: string): Promise<void>
  • 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.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • Optional reason: string

      The reason for requesting to join the group.

    Returns Promise<void>

  • setMemberAttribute(groupId: string, member: string, attributes: Record<string, string>): Promise<void>
  • Sets custom attributes of a group member.

    throws

    A description of the exception. See ChatError.

    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>

  • setNativeListener(event: NativeEventEmitter): void
  • Parameters

    • event: NativeEventEmitter

    Returns void

  • unMuteAllMembers(groupId: string): Promise<void>
  • Unmutes all group members.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • unMuteMembers(groupId: string, members: string[]): Promise<void>
  • Unmutes group members.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

      The array of user IDs of members to be unmuted.

    Returns Promise<void>

  • unblockGroup(groupId: string): Promise<void>
  • Unblocks group messages.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    Returns Promise<void>

  • unblockMembers(groupId: string, members: string[]): Promise<void>
  • Removes users from the group block list.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • members: string[]

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

    Returns Promise<void>

  • updateGroupAnnouncement(groupId: string, announcement: string): Promise<void>
  • Updates the group announcement.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • announcement: string

      The group announcement.

    Returns Promise<void>

  • updateGroupExtension(groupId: string, extension: string): Promise<void>
  • Updates the group extension field.

    Only the group owner or admin can call this method.

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • extension: string

      The updated group extension field.

    Returns Promise<void>

  • Uploads the shared file to the group.

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

    throws

    A description of the exception. See ChatError.

    Parameters

    • groupId: string

      The group ID.

    • filePath: string

      The local path of the shared file.

    • Optional callback: ChatGroupFileStatusCallback

      (Optional) The file upload result callback.

    Returns Promise<void>

  • _callMethod<T>(method: string, args?: {}): Promise<T>
  • Type Parameters

    • T

    Parameters

    • method: string
    • Optional args: {}

      Returns Promise<T>

    • checkErrorFromResult(result: any): void
    • Parameters

      • result: any

      Returns void

    • handleGroupFileCallback(methodName: string, self: BaseManager, groupId: string, filePath: string, callback?: ChatGroupFileStatusCallback): void
    • Parameters

      Returns void

    Generated using TypeDoc