Options
All
  • Public
  • Public/Protected
  • All
Menu

export manager

Hierarchy

  • BaseManager
    • ChatClient

Index

Constructors

  • Returns ChatClient

Properties

_chatManager: ChatManager
_chatRoomManager: ChatRoomManager
_connectionListeners: Set<ChatConnectEventListener>
_connectionSubscriptions: Map<string, EmitterSubscription>
_contactManager: ChatContactManager
_currentUsername: string = ''
_customListeners: Set<ChatCustomEventListener>
_eventEmitter?: NativeEventEmitter
_groupManager: ChatGroupManager
_isInit: boolean = false
_multiDeviceListeners: Set<ChatMultiDeviceEventListener>
_options?: ChatOptions
_presenceManager: ChatPresenceManager
_pushManager: ChatPushManager
_rnSdkVersion: string = '1.1.0'
_sdkVersion: string = '4.0.0'
_userInfoManager: ChatUserInfoManager
TAG: string = 'ChatClient'
_instance: ChatClient
eventType: number = 2

Accessors

  • Gets the chat manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatManager

    The chat manager class.

  • Gets the contact manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatContactManager

    The contact manager class.

  • get currentUserName(): string
  • Gets the current logged-in user ID.

    Note

    The user ID for successful login is valid.

    The user ID is obtained from the memory and updated in the case of login, logout, and reconnection upon disconnection. You can call getCurrentUsername to get the latest data from the server.

    Returns string

    The current logged-in user ID.

  • Gets the chat group manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatGroupManager

    The chat group manager class.

  • Gets the SDK configurations.

    Ensure that you set the SDK options during initialization. See ChatOptions.

    Returns undefined | ChatOptions

    The SDK configurations.

  • Gets the presence manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatPresenceManager

    The presence manager class.

  • Gets the push manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatPushManager

    The push manager class.

  • Gets the chat room manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatRoomManager

    The chat room manager class.

  • Gets the user information manager class.

    This method can be called only after the chat client is initialized.

    Returns ChatUserInfoManager

    The user information manager class.

  • get version(): string
  • Returns string

Methods

  • Adds the connection status listener.

    Parameters

    Returns void

  • Adds a custom listener to receive data that the iOS or Android devices send to the React Native layer.

    Parameters

    Returns void

  • changeAppKey(newAppKey: string): Promise<void>
  • Updates the App Key, which is the unique identifier used to access the chat service.

    Note

    • As this key controls access to the chat service for your app, you can only update the key when the current user is logged out.

    • Updating the App Key means to switch to a new App Key.

    • You can retrieve the new App Key from the Console.

    • You can also set an App Key by using the ChatOptions.appKey method when logged out.

    throws

    A description of the exception. See ChatError.

    Parameters

    • newAppKey: string

      The new App Key. Ensure that you set this parameter.

    Returns Promise<void>

  • compressLogs(): Promise<undefined | string>
  • Compresses the debug log file into a gzip archive.

    We strongly recommend that you delete this debug archive once it is no longer used.

    throws

    A description of the exception. See ChatError.

    Returns Promise<undefined | string>

    The path of the compressed gzip file.

  • createAccount(userId: string, password: string): Promise<void>
  • Creates a new user (open registration).

    Note

    There are two registration modes:

    • Open registration: This mode is for testing use, but not recommended in a formal environment; If a call failure occurs, you can contact our business manager.

    • Authorized registration: You can create a new user through a REST API, and then save it to your server or return it to the client.

    throws

    A description of the exception. See ChatError.

    Parameters

    • userId: string

      The user ID. Ensure that you set this parameter. The user ID can be a maximum of 64 characters of the following types: - 26 English letters (a-z) - 10 numbers (0-9), - "", "-", "." The user ID is case-insensitive, so Aa and aa are the same user ID. The email address or the UUID of the user cannot be used as the user ID. You can also set this parameter with the regular expression ^[a-zA-Z0-9-]+$.

    • password: string

      The password. Ensure that you set this parameter. The password can contain a maximum of 64 characters.

    Returns Promise<void>

  • getAccessToken(): Promise<string>
  • Gets the token for login.

    throws

    A description of the exception. See ChatError.

    Returns Promise<string>

    The token for login.

  • getCurrentUsername(): Promise<string>
  • Gets the current logged-in user ID from the server.

    Note

    To get the current logged-in user ID from the memory, see currentUserName.

    throws

    A description of the exception. See ChatError.

    Returns Promise<string>

    The logged-in user ID.

  • getEventEmitter(): NativeEventEmitter
  • Returns NativeEventEmitter

  • getLoggedInDevicesFromServer(userId: string, pwdOrToken: string, isPassword?: boolean): Promise<ChatDeviceInfo[]>
  • Gets the list of online devices to which you have logged in with a specified account.

    throws

    A description of the exception. See ChatError.

    Parameters

    • userId: string

      The user ID.

    • pwdOrToken: string

      The password or token.

    • Optional isPassword: boolean

      If true, use password, otherwise use token. Default is true. See {@link pwdOrToken}

    Returns Promise<ChatDeviceInfo[]>

    The list of the online logged-in devices.

  • Initializes the SDK.

    Note

    • Make sure to initialize the SDK in the main thread.
    • This method must be called before any other methods are called.
    throws

    A description of the exception. See ChatError.

    Parameters

    Returns Promise<void>

  • isConnected(): Promise<boolean>
  • Checks whether the SDK is connected to the chat server.

    throws

    A description of the exception. See ChatError.

    Returns Promise<boolean>

    Whether the SDK is connected to the chat server. - true: Yes. - false: No.

  • isLoginBefore(): Promise<boolean>
  • Checks whether the current user is logged in to the app.

    Note

    This method needs to be called after initialization and before login.

    throws

    A description of the exception. See ChatError.

    Returns Promise<boolean>

    Whether the user is logged in to the app: - true: The user is logged in to the app. In automatic login mode, the SDK returns true before successful login and false otherwise. - false: The user is not logged in to the app. In non-automatic login mode, the SDK returns false.

  • kickAllDevices(userId: string, pwdOrToken: string, isPassword?: boolean): Promise<void>
  • Logs out from a specified account on all devices.

    throws

    A description of the exception. See ChatError.

    Parameters

    • userId: string

      The user ID.

    • pwdOrToken: string

      The password or token.

    • Optional isPassword: boolean

      Whether the password or user token is used. See {@link pwdOrToken}.

      • (Default)true:The password is used.
      • false: The user token is used.

    Returns Promise<void>

  • kickDevice(userId: string, pwdOrToken: string, resource: string, isPassword?: boolean): Promise<void>
  • Logs out from a specified account on a device.

    For how to get the device ID, see ChatDeviceInfo.resource.

    throws

    A description of the exception. See ChatError.

    Parameters

    • userId: string

      The user ID.

    • pwdOrToken: string

      The password or token.

    • resource: string

      The device ID. See ChatDeviceInfo.resource.

    • Optional isPassword: boolean

      Whether the password or user token is used. See {@link pwdOrToken}.

      • (Default)true:The password is used.
      • false: The user token is used.

    Returns Promise<void>

  • login(userId: string, pwdOrToken: string, isPassword?: boolean): Promise<void>
  • Logs in to the chat server with a password or an Easemob token. An exception message is thrown if the login fails.

    Note

    If you use an Easemob token to log in to the server, you can get the token in either of the following ways:

    The token expiration reminder is notified by the two callback methods: ChatConnectEventListener.onTokenWillExpire and ChatConnectEventListener.onTokenDidExpire.

    throws

    A description of the exception. See ChatError.

    Parameters

    • userId: string

      The user ID. See createAccount.

    • pwdOrToken: string

      The password or token. See createAccount or getAccessToken

    • isPassword: boolean = true

      Whether to log in with a password or a token. - true: A token is used. - (Default) false: A password is used.

    Returns Promise<void>

  • loginWithAgoraToken(userId: string, agoraToken: string): Promise<void>
  • Logs in to the chat server with the user ID and an Agora token. An exception message is thrown if the login fails.

    Note

    The Agora token is different from token {@link login.token} provided by Easemob.

    This method supports automatic login.

    throws

    A description of the exception. See ChatError.

    Parameters

    • userId: string

      The user ID. See createAccount.

    • agoraToken: string

      The Agora token.

    Returns Promise<void>

  • logout(unbindDeviceToken?: boolean): Promise<void>
  • Logs out of the chat app. An exception message is thrown if the logout fails.

    throws

    A description of the exception. See ChatError.

    Parameters

    • unbindDeviceToken: boolean = true

      Whether to unbind the token upon logout. This parameter is available only to mobile platforms.

      • (Default) true: Yes.
      • false: No.

    Returns Promise<void>

  • onAppActiveNumberReachLimit(): void
  • Returns void

  • onConnected(): void
  • Returns void

  • onCustomEvent(params: any): void
  • Parameters

    • params: any

    Returns void

  • onDisconnected(params?: any): void
  • Parameters

    • Optional params: any

    Returns void

  • onMultiDeviceEvent(params?: any): void
  • Parameters

    • Optional params: any

    Returns void

  • onTokenDidExpire(params?: any): void
  • Parameters

    • Optional params: any

    Returns void

  • onTokenWillExpire(params?: any): void
  • Parameters

    • Optional params: any

    Returns void

  • onUserAuthenticationFailed(): void
  • Returns void

  • onUserDidChangePassword(): void
  • Returns void

  • onUserDidForbidByServer(): void
  • Returns void

  • onUserDidLoginFromOtherDevice(params: any): void
  • Parameters

    • params: any

    Returns void

  • onUserDidLoginTooManyDevice(): void
  • Returns void

  • onUserDidRemoveFromServer(): void
  • Returns void

  • onUserKickedByOtherDevice(): void
  • Returns void

  • removeAllConnectionListener(): void
  • Removes all the connection status listeners for the chat server.

    Returns void

  • removeAllCustomListener(): void
  • Removes all the custom listeners.

    Returns void

  • removeAllMultiDeviceListener(): void
  • Removes all the multi-device listeners.

    Returns void

  • Removes the connection status listener.

    Parameters

    Returns void

  • Removes a custom listener to stop receiving data that the iOS or Android devices send to the React Native layer.

    Parameters

    Returns void

  • Removes the specified multi-device listener.

    Parameters

    Returns void

  • renewAgoraToken(agoraToken: string): Promise<void>
  • Renews the Agora token.

    Note

    If you log in with an Agora token and are notified by the callback method ChatConnectEventListener that the token is to expire, you can call this method to update the token to avoid unknown issues caused by an invalid token.

    throws

    A description of the exception. See ChatError.

    Parameters

    • agoraToken: string

      The new Agora token.

    Returns Promise<void>

  • reset(): void
  • Returns void

  • setEventEmitter(): void
  • Returns void

  • setNativeListener(event: NativeEventEmitter): void
  • Parameters

    • event: NativeEventEmitter

    Returns void

  • Update push configurations.

    Note For the iOS platform, you need to pass the device ID during initialization. Otherwise, the push function cannot be used properly. See ChatClient.init

    throws

    A description of the exception. See ChatError.

    Parameters

    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