import type { NativeEventEmitter } from 'react-native'; import type { ChatGroupEventListener } from './ChatEvents'; import { ChatGroupSharedFile, ChatGroup, ChatGroupOptions, ChatGroupInfo, ChatGroupFileStatusCallback } from './common/ChatGroup'; import { ChatCursorResult } from './common/ChatCursorResult'; import { BaseManager } from './__internal__/Base'; /** * The group manager class, which manages group creation and deletion, user joining and exiting the group, etc. */ export declare class ChatGroupManager extends BaseManager { protected static TAG: string; private _groupListeners; private _groupSubscriptions; constructor(); setNativeListener(event: NativeEventEmitter): void; private invokeGroupListener; private static handleUploadFileCallback; private static handleDownloadFileCallback; /** * Gets the group instance from the cache by group ID. * * @param groupId The group ID. * @returns The group instance. Returns undefined if the group does not exist. * * @throws A description of the exception. See {@link ChatError}. */ getGroupWithId(groupId: string): Promise; /** * Gets all groups of the current user from the cache. * * @returns The group list. * * @throws A description of the exception. See {@link ChatError}. */ getJoinedGroups(): Promise>; /** * Gets all joined groups of the current user 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 {@link #fetchMemberListFromServer}. * * @param pageSize The number of pages. * @param pageNum The page number. * @returns The list of groups that the current user joins. * * @throws A description of the exception. See {@link ChatError}. */ fetchJoinedGroupsFromServer(pageSize: number, pageNum: number): Promise>; /** * Gets public groups from the server with pagination. * * @param pageSize The number of pages. * @param cursor The cursor position from which to start to get data next time. Sets the parameter as null for the first time. * @returns The result of {@link ChatCursorResult}, including the cursor for getting data next time and the group list. * * @throws A description of the exception. See {@link ChatError}. */ fetchPublicGroupsFromServer(pageSize: number, cursor?: string): Promise>; /** * Creates a group instance. * * After the group is created, the data in the cache and database will be updated and multiple devices will receive the notification event and update the group data to the cache and database. * * You can set {@link ChatGroupEventListener} to listen for the event. * * @param options The options for creating a group. See {@link ChatGroupOptions}. * The options are as follows: * - The maximum number of group members. The default value is 200. * - The group style. See {@link ChatGroupStyle}. The default value is {@link ChatGroupStyle#PrivateOnlyOwnerInvite}. * @param groupName The group name. * @param desc The group description. * @param inviteMembers The group member array. The group owner ID is optional. * @param inviteReason The group joining invitation. * @returns The created group instance. * * @throws A description of the exception. See {@link ChatError}. */ createGroup(options: ChatGroupOptions, groupName: string, desc?: string, inviteMembers?: Array, inviteReason?: string): Promise; /** * Gets the group information from the server. * * This method does not get member information. If member information is required, call {@link #fetchMemberListFromServer}. * * @param groupId The group ID. * @returns The group instance. Returns undefined if the group does not exist. * * @throws A description of the exception. See {@link ChatError}. */ fetchGroupInfoFromServer(groupId: string): Promise; /** * Gets the member list of the group with pagination. * * @param groupId The group ID. * @param pageSize The number of group members per page. * @param cursor The cursor position from which to start to get data next time. Sets the parameter as null for the first time. * @returns The result of {@link ChatCursorResult}, including the cursor for getting data next time and the group member list. * * @throws A description of the exception. See {@link ChatError}. */ fetchMemberListFromServer(groupId: string, pageSize?: number, cursor?: string): Promise>; /** * Gets the group block list from server with pagination. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param pageSize The number of groups per page. * @param pageNum The page number, starting from 1. * @returns The group block list. * * @throws A description of the exception. See {@link ChatError}. */ fetchBlockListFromServer(groupId: string, pageSize?: number, pageNum?: number): Promise>; /** * Gets the mute list of the group from the server. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param pageSize The number of muted members per page. * @param pageNum The page number, starting from 1. * @returns The group mute list. * * @throws A description of the exception. See {@link ChatError}. */ fetchMuteListFromServer(groupId: string, pageSize?: number, pageNum?: number): Promise>; /** * Gets the allow list of the group from the server. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @returns The allow list of the group. * * @throws A description of the exception. See {@link ChatError}. */ fetchWhiteListFromServer(groupId: string): Promise>; /** * Gets whether the member is on the allow list of the group. * * @param groupId The group ID. * @returns A Boolean value to indicate whether the current user is on the allow list of the group; * * @throws A description of the exception. See {@link ChatError}. */ isMemberInWhiteListFromServer(groupId: string): Promise; /** * Gets the shared files of the group from the server. * * @param groupId The group ID. * @param pageSize The number of shared files per page. * @param pageNum The page number, starting from 1. * @returns The shared file list. * * @throws A description of the exception. See {@link ChatError}. */ fetchGroupFileListFromServer(groupId: string, pageSize?: number, pageNum?: number): Promise>; /** * Gets the group announcement from the server. * * Group members can call this method. * * @param groupId The group ID. * @returns The group announcement. * * @throws A description of the exception. See {@link ChatError}. */ fetchAnnouncementFromServer(groupId: string): Promise; /** * Adds users to the group. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The array of new members to add. * @param welcome (option) The welcome message. * * @throws A description of the exception. See {@link ChatError}. */ addMembers(groupId: string, members: Array, welcome?: string): Promise; /** * Invites users to join the group. * * This method works only for groups with the style of `PrivateOnlyOwnerInvite`, `PrivateMemberCanInvite`, or `PublicJoinNeedApproval`. * For a group with the PrivateOnlyOwnerInvite style, only the group owner can invite users to join the group; * For a group with the PrivateMemberCanInvite style, each group member can invite users to join the group. * * @param groupId The group ID. * @param members The array of new members to invite. * @param reason The invitation reason. * * @throws A description of the exception. See {@link ChatError}. */ inviterUser(groupId: string, members: Array, reason?: string): Promise; /** * Removes a member from the group. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The username of the member to be removed. * * @throws A description of the exception. See {@link ChatError}. */ removeMembers(groupId: string, members: Array): Promise; /** * 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. * * @param groupId The group ID. * @param members The list of users to be added to the block list. * * @throws A description of the exception. See {@link ChatError}. */ blockMembers(groupId: string, members: Array): Promise; /** * Removes users from the group block list. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The users to be removed from the group block list. * * @throws A description of the exception. See {@link ChatError}. */ unblockMembers(groupId: string, members: Array): Promise; /** * Changes the group name. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param name The new group name. * * @throws A description of the exception. See {@link ChatError}. */ changeGroupName(groupId: string, name: string): Promise; /** * Changes the group description. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param desc The new group description. * * @throws A description of the exception. See {@link ChatError}. */ changeGroupDescription(groupId: string, desc: string): Promise; /** * * Leaves a group. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ leaveGroup(groupId: string): Promise; /** * Destroys the group instance. * * Only the group owner can call this method. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ destroyGroup(groupId: string): Promise; /** * Blocks group messages. * * The user that blocks group messages is still a group member, but can't receive group messages. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ blockGroup(groupId: string): Promise; /** * Unblocks group messages. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ unblockGroup(groupId: string): Promise; /** * Transfers the group ownership. * * Only the group owner can call this method. * * @param groupId The group ID. * @param newOwner The new owner ID. * * @throws A description of the exception. See {@link ChatError}. */ changeOwner(groupId: string, newOwner: string): Promise; /** * Adds a group admin. * * Only the group owner can call this method and group admins cannot. * * @param groupId The group ID. * @param admin The username of the admin to add. * * @throws A description of the exception. See {@link ChatError}. */ addAdmin(groupId: string, admin: string): Promise; /** * Removes a group admin. * * Only the group owner can call this method. * * @param groupId The group ID. * @param admin The username of the admin to remove. * * @throws A description of the exception. See {@link ChatError}. */ removeAdmin(groupId: string, admin: string): Promise; /** * Mutes group members. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The list of members to be muted. * @param duration The mute duration in milliseconds. * * @throws A description of the exception. See {@link ChatError}. */ muteMembers(groupId: string, members: Array, duration?: number): Promise; /** * Cancel mutes group members. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The list of members to be muted. * * @throws A description of the exception. See {@link ChatError}. */ unMuteMembers(groupId: string, members: Array): Promise; /** * Mutes all members. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ muteAllMembers(groupId: string): Promise; /** * Cancel mute all group members. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ unMuteAllMembers(groupId: string): Promise; /** * Adds members to the allow list of the group. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The members to be added to the allow list of the group. * * @throws A description of the exception. See {@link ChatError}. */ addWhiteList(groupId: string, members: Array): Promise; /** * Removes members from the allow list of the group. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param members The members to be removed from the allow list of the group. * * @throws A description of the exception. See {@link ChatError}. */ removeWhiteList(groupId: string, members: Array): Promise; /** * Uploads the shared file to the group. * * When a shared file is uploaded, the upload progress callback will be triggered. * * @param groupId The group ID. * @param filePath The local path of the shared file. * @param callback (option) The result for file upload. * * @throws A description of the exception. See {@link ChatError}. */ uploadGroupSharedFile(groupId: string, filePath: string, callback?: ChatGroupFileStatusCallback): Promise; /** * Downloads the shared file of the group. * * @param groupId The group ID. * @param fileId The ID of the shared file. * @param savePath The local path of the shared file. * @param callback (option) The result for file download. * * @throws A description of the exception. See {@link ChatError}. */ downloadGroupSharedFile(groupId: string, fileId: string, savePath: string, callback?: ChatGroupFileStatusCallback): Promise; /** * 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. * * @param groupId The group ID. * @param fileId The ID of the shared file. * * @throws A description of the exception. See {@link ChatError}. */ removeGroupSharedFile(groupId: string, fileId: string): Promise; /** * Updates the group announcement. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param announcement The group announcement. * * @throws A description of the exception. See {@link ChatError}. */ updateGroupAnnouncement(groupId: string, announcement: string): Promise; /** * Updates the group extension field. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param extension The group extension field. * * @throws A description of the exception. See {@link ChatError}. */ updateGroupExtension(groupId: string, extension: string): Promise; /** * Joins a public group. * * For a group that requires no authentication,users can join it freely without obtaining permissions from the group owner. * For a group that requires authentication, users need to wait for the group owner to agree before joining the group. For details, see {@link ChatGroupStyle}. * * @param groupId The group ID. * * @throws A description of the exception. See {@link ChatError}. */ joinPublicGroup(groupId: string): Promise; /** * Requests to join a group. * * This method works only for public groups requiring authentication, i.e., groups with the style of {@link ChatGroupStyle#PublicJoinNeedApproval}. * * @param groupId The group ID. * @param reason The reason for requesting to join the group. * * @throws A description of the exception. See {@link ChatError}. */ requestToJoinPublicGroup(groupId: string, reason?: string): Promise; /** * Approves a group request. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param username The username of the user who sends a request to join the group. * * @throws A description of the exception. See {@link ChatError}. */ acceptJoinApplication(groupId: string, username: string): Promise; /** * Declines a group request. * * Only the group owner or admin can call this method. * * @param groupId The group ID. * @param username The username of the user who sends a request to join the group. * @param reason The reason of declining. * * @throws A description of the exception. See {@link ChatError}. */ declineJoinApplication(groupId: string, username: string, reason?: string): Promise; /** * Accepts a group invitation. * * @param groupId The group ID. * @param inviter The user who initiates the invitation. * * @throws A description of the exception. See {@link ChatError}. */ acceptInvitation(groupId: string, inviter: string): Promise; /** * Declines a group invitation. * * @param groupId The group ID. * @param inviter The username of the inviter. * @param reason The reason of declining. * * @throws A description of the exception. See {@link ChatError}. */ declineInvitation(groupId: string, inviter: string, reason?: string): Promise; /** * Add contact listener * * @param listener The listener to be added. */ addGroupListener(listener: ChatGroupEventListener): void; /** * Remove contact listener * * @param listener The listener to be deleted. */ removeGroupListener(listener: ChatGroupEventListener): void; /** * Clear contact listener */ removeAllGroupListener(): void; }