The chat room manager class, which manages user operations, like joining and leaving the chat room and retrieving the chat room list, and manages member privileges.

Hierarchy

  • Native
    • ChatRoomManager

Constructors

Methods

  • Sets custom chat room attributes.

    Parameters

    • params: {
          attributes: {
              [x: string]: string;
          }[];
          deleteWhenLeft?: boolean;
          overwrite?: boolean;
          roomId: string;
      }
      • attributes: {
            [x: string]: string;
        }[]
      • OptionaldeleteWhenLeft?: boolean
      • Optionaloverwrite?: boolean
      • roomId: string

    Returns Promise<Map<string, string>>

    If certain attributes fail to be set, the SDK returns a map of the attributes in key-value format, where the key is the attribute key and the value is the reason for the failure.

    params

    • roomId The chat room ID.
    • attributes The chat room attributes to add. The attributes are in key-value format. In a key-value pair, the key is the attribute name that can contain 128 characters at most; the value is the attribute value that cannot exceed 4096 characters. A chat room can have a maximum of 100 custom attributes and the total length of custom chat room attributes cannot exceed 10 GB for each app. Attribute keys support the following character sets:
      • 26 lowercase English letters (a-z)
      • 26 uppercase English letters (A-Z)
      • 10 numbers (0-9)
      • "_", "-", "."
    • deleteWhenLeft: Whether to delete the chat room attributes set by the member when he or she exits the chat room.
      • (Default)true: Yes.
      • false: No.
    • overwrite: Whether to overwrite the attributes with same key set by others.
      • true: Yes.
      • (Default)false: No.

    A description of the exception. See ChatError.

  • Adds a chat room admin.

    Only the chat room owner can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • admin: string

      The user ID of the chat room admin to be added.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Adds members to the allow list of the chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

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

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Adds a chat room listener.

    Parameters

    Returns void

  • Adds the specified members to the block list of the chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

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

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Modifies the chat room description.

    Only the chat room owner can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • description: string

      The new description of the chat room.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Changes the chat room name.

    Only the chat room owner can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • subject: string

      The new name of the chat room.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Transfers the chat room ownership.

    Only the chat room owner can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • newOwner: string

      The user ID of the new chat room owner.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Creates a chat room.

    Parameters

    • subject: string

      The chat room name.

    • Optionaldescription: string

      The chat room description.

    • Optionalwelcome: string

      A welcome message for new chat room members.

    • Optionalmembers: string[]

      The list of members invited to join the chat room.

    • maxCount: number = 300

      The maximum number of members allowed to join the chat room.

    Returns Promise<ChatRoom>

    The chat room instance.

    A description of the exception. See ChatError.

  • Destroys a chat room.

    Only the chat room owner can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Gets the allow list from the server.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<string[]>

    The allow list of the chat room.

    A description of the exception. See ChatError.

  • Gets the chat room announcement from the server.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<undefined | string>

    The chat room announcement.

    A description of the exception. See ChatError.

  • Gets custom chat room attributes from the server.

    Parameters

    • roomId: string

      The chat room ID.

    • Optionalkeys: string[]

      The key list of custom attributes to get. If you set it as null or leave it empty, this method retrieves all custom attributes.

    Returns Promise<Map<string, string>>

    Custom chat room attributes in key-value format.

    A description of the exception. See ChatError.

  • Gets the chat room block list with pagination.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • pageNum: number = 1

      The page number, starting from 1.

    • pageSize: number = 200

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

    Returns Promise<string[]>

    The user IDs of the chat room members on the block list.

    A description of the exception. See ChatError.

  • Gets the details of the chat room from the server.

    By default, the details do not include the chat room member list.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<undefined | ChatRoom>

    The chat room instance. The SDK returns undefined if the chat room does not exist.

    A description of the exception. See ChatError.

  • Gets the chat room member list.

    Parameters

    • roomId: string

      The chat room ID.

    • cursor: string = ''

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

    • pageSize: number = 200

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

    Returns Promise<ChatCursorResult<string>>

    The list of chat room members and the cursor for the next query. See ChatCursorResult.

    A description of the exception. See ChatError.

  • Uses the pagination to get the list of members who are muted in the chat room.

    This method gets data from the server.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • pageNum: number = 1

      The page number, starting from 1.

    • pageSize: number = 200

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

    Returns Promise<string[]>

    The user IDs of muted members.

    A description of the exception. See ChatError.

  • Gets chat room data from the server with pagination.

    Parameters

    • pageNum: number = 1

      The page number, starting from 1.

    • pageSize: number = 200

      The number of chat rooms that you expect to get on each page.

    Returns Promise<ChatPageResult<ChatRoom>>

    The list of obtained chat rooms. See ChatPageResult.

    A description of the exception. See ChatError.

  • Gets the chat room by ID from the local database.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<undefined | ChatRoom>

    The chat room instance. The SDK returns undefined if the chat room does not exist.

    A description of the exception. See ChatError.

  • Checks whether the member is on the allow list of the chat room.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<boolean>

    Whether the member is on the allow list of the chat room. - true: Yes. - false: No.

    A description of the exception. See ChatError.

  • Joins the chat room.

    To leave the chat room, you can call leaveChatRoom.

    Parameters

    • roomId: string

      The ID of the chat room to join.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Leaves the chat room.

    Parameters

    • roomId: string

      The ID of the chat room to leave.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Mutes all members.

    Only the chat room owner or admin can call this method.

    The chat room owner, admins, and members added to the allow list cannot be muted.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Mutes the specified members in a chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • muteMembers: string[]

      The user IDs of members to be muted.

    • duration: number = -1

      The mute duration in milliseconds.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes all the chat room listeners.

    Returns void

  • Removes custom chat room attributes.

    Parameters

    • params: {
          forced?: boolean;
          keys: string[];
          roomId: string;
      }
      • Optionalforced?: boolean
      • keys: string[]
      • roomId: string

    Returns Promise<Map<string, string>>

    If certain attributes fail to be removed, the SDK returns a map of the attributes in key-value format, where the key is the attribute key and the value is the reason for the failure.

    params

    • roomId: The chat room ID.
    • keys: The keys of the chat room attributes to remove.
    • forced: Whether to remove the attributes with same key set by others.
      • true: Yes.
      • (Default)false: No.

    A description of the exception. See ChatError.

  • Removes administrative privileges of a chat room admin.

    Parameters

    • roomId: string

      The chat room ID.

    • admin: string

      The user ID of the chat room admin whose administrative privileges are to be removed.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes the specified members from a chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

      The user IDs of the members to be removed.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes members from the allow list of the chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

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

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Removes the chat room listener.

    Parameters

    Returns void

  • Parameters

    • event: NativeEventEmitter

    Returns void

  • Removes the specified members from the block list of the chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • members: string[]

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

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Unmutes all members of the chat room.

    Only the chat room owner or admins can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Unmutes the specified members in a chat room.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • unMuteMembers: string[]

      The user IDs of members to be unmuted.

    Returns Promise<void>

    A description of the exception. See ChatError.

  • Updates the chat room announcement.

    Only the chat room owner or admin can call this method.

    Parameters

    • roomId: string

      The chat room ID.

    • announcement: string

      The new chat room announcement.

    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