import { EventEmitter, NativeEventEmitter } from 'react-native'; import { ChatContactManager } from './ChatContactManager'; import { ChatConnectEventListener, ChatCustomEventListener, ChatMultiDeviceEventListener } from './ChatEvents'; import { ChatGroupManager } from './ChatGroupManager'; import { ChatManager } from './ChatManager'; import { ChatPresenceManager } from './ChatPresenceManager'; import { ChatPushManager } from './ChatPushManager'; import { ChatRoomManager } from './ChatRoomManager'; import { ChatUserInfoManager } from './ChatUserInfoManager'; import { ChatDeviceInfo } from './common/ChatDeviceInfo'; import type { ChatOptions } from './common/ChatOptions'; import { BaseManager } from './__internal__/Base'; export declare class ChatClient extends BaseManager { static eventType: number; protected static TAG: string; private static _instance; private _connectionSubscriptions; static getInstance(): ChatClient; private setEventEmitter; getEventEmitter(): EventEmitter; private _chatManager; private _groupManager; private _contactManager; private _chatRoomManager; private _pushManager; private _userInfoManager; private _presenceManager; private _connectionListeners; private _multiDeviceListeners; private _customListeners; private _options?; private _sdkVersion; private _isInit; private _currentUsername; private constructor(); setNativeListener(event: NativeEventEmitter): void; private onConnected; private onDisconnected; private onTokenWillExpire; private onTokenDidExpire; private onMultiDeviceEvent; private onCustomEvent; private onUserDidLoginFromOtherDevice; private onUserDidRemoveFromServer; private onUserDidForbidByServer; private onUserDidChangePassword; private onUserDidLoginTooManyDevice; private onUserKickedByOtherDevice; private onUserAuthenticationFailed; private reset; /** * Gets the configurations. Make sure to set the param, see {@link EMOptions}. * * This value is set during initialization. * * @returns The configurations. */ get options(): ChatOptions | undefined; /** * Gets the current logged-in user ID. * * The value is valid after successful login. * * The value is cached locally and is updated on login, logout, disconnect, etc. Use {@link getCurrentUsername} if you need a more accurate value. * * @returns The current logged-in user ID. */ get currentUserName(): string; /** * Gets the version of the React Native SDK. * * @returns The version of the React Native SDK. */ get rnSdkVersion(): string; /** * Initializes the SDK. * Make sure to initialize the SDK in the main thread. * * **Note** * * **This method must be called before any method can be called.** * * @param options The options for SDK initialization. The options are required. See {@link ChatOptions}. * * @throws A description of the exception. See {@link ChatError}. */ init(options: ChatOptions): Promise; /** * Checks whether the SDK is connected to the chat server. * * @returns Whether the SDK is connected to the chat server. * - `true`: Yes. * - `false`: No. * * @throws A description of the exception. See {@link ChatError}. */ isConnected(): Promise; /** * Gets the current logged-in user ID from the server. To get it from the memory, see {@link currentUserName}. * @returns The logged-in user ID. * * @throws A description of the exception. See {@link ChatError}. */ getCurrentUsername(): Promise; /** * Checks whether the user is logged into the app. * * **Note** * * This state is after initialization and before login. * * @returns * - `true`: In automatic login mode, the value is true before successful login and false otherwise. * - `false`: In non-automatic login mode, the value is false. * * @throws A description of the exception. See {@link ChatError}. */ isLoginBefore(): Promise; /** * Gets the token for login. * * @returns The token. * * @throws A description of the exception. See {@link ChatError}. */ getAccessToken(): Promise; /** * Creates a new user. * * @param username The user ID. * This parameter is required. The user ID can be a maximum of 64 characters of the following types: * - 26 English letters (a-z) * - 10 numbers (0-9), * - "_", "-", "." * This parameter is case insensitive and upper-case letters are automatically changed to low-case ones. * Also, you can set this parameter with a regular expression in the format of ^[a-zA-Z0-9_-]+$. * @param password The password. It is required. The password can contain a maximum of 64 characters. * * @throws A description of the exception. See {@link ChatError}. */ createAccount(username: string, password: string): Promise; /** * Logs into the chat server with a password or a token. * * @param userName The user ID. See {@link createAccount}. * @param pwdOrToken The password or token. See {@link createAccount} or {@link getAccessToken} * @param isPassword Whether to log in with a password or a token. * - `true`: A token is used. * - (Default) `false`: A password is used. * * @throws A description of the exception. See {@link ChatError}. */ login(userName: string, pwdOrToken: string, isPassword?: boolean): Promise; /** * Logs into the chat server with the user ID and an Agora token. * This method supports automatic login. * * @param userName The user ID. See {@link createAccount}. * @param agoraToken The Agora token. * * @throws A description of the exception. See {@link ChatError}. */ loginWithAgoraToken(userName: string, agoraToken: string): Promise; /** * Renews the Agora token. * * If you log in with an Agora token and are notified by a callback method {@link ChatConnectEventListener} that the token is to be expired, you can call this method to update the token to avoid unknown issues caused by an invalid token. * * @param agoraToken The new Agora token. * * @throws A description of the exception. See {@link ChatError}. */ renewAgoraToken(agoraToken: string): Promise; /** * Logs out of the chat app. * * @param unbindDeviceToken Whether to unbind the token upon logout. * - (Default) `true`: Yes. * - `false`: No. * @throws A description of the exception. See {@link ChatError}. */ logout(unbindDeviceToken?: boolean): Promise; /** * Updates the App Key, which is the unique identifier used to access Chat service. * * You can retrieve the new App Key from the Console. * * As this key controls all access to Chat service for your app, you can only update the key when the current user is logged out. * * Also, you can set App Key by the following method when logged out: {@link ChatOptions#appKey}. * * @param newAppKey The App Key. It is required * * @throws A description of the exception. See {@link ChatError}. */ changeAppKey(newAppKey: string): Promise; /** * Compresses the debug log into a gzip archive. * * We recommend that you delete this debug archive once it is no longer used. * * @returns The path of the compressed gzip file. * * @throws A description of the exception. See {@link ChatError}. */ compressLogs(): Promise; /** * Gets all the information about the devices which you have logged into with a specified account. * * @param username The user ID. * @param password The password. * @returns The list of the login devices. * * @throws A description of the exception. See {@link ChatError}. */ getLoggedInDevicesFromServer(username: string, password: string): Promise>; /** * Logs out from a specified account on a device. * For how to get the device ID, see {@link ChatDeviceInfo#resource}. * * @param username The user ID. * @param password The password. * @param resource The device ID. See {@link ChatDeviceInfo#resource}. * * @throws A description of the exception. See {@link ChatError}. */ kickDevice(username: string, password: string, resource: string): Promise; /** * Logs out from a specified account on all devices. * * @param username The user ID. * @param password The password. * * @throws A description of the exception. See {@link ChatError}. */ kickAllDevices(username: string, password: string): Promise; /** * Adds the connection listener for the chat server. * * @param listener The chat server connection listener to be added. */ addConnectionListener(listener: ChatConnectEventListener): void; /** * Removes the connection listener for the chat server. * * @param listener The chat server connection listener to be removed. */ removeConnectionListener(listener: ChatConnectEventListener): void; /** * Removes all the connection listeners for the chat server. */ removeAllConnectionListener(): void; /** * Adds the multi-device listener. * * @param listener The multi-device listener to be added. */ addMultiDeviceListener(listener: ChatMultiDeviceEventListener): void; /** * Removes the multi-device listener. * * @param listener The multi-device listener to be removed. */ removeMultiDeviceListener(listener: ChatMultiDeviceEventListener): void; /** * Removes all the multi-device listeners. */ removeAllMultiDeviceListener(): void; /** * Adds a custom listener to receive data from iOS or Android devices. * * @param listener The custom listener to be added. */ addCustomListener(listener: ChatCustomEventListener): void; /** * Removes a custom listener to receive data from iOS or Android devices. * * @param listener The custom listener to be removed. */ removeCustomListener(listener: ChatCustomEventListener): void; /** * Removes all the custom listeners. */ removeAllCustomListener(): void; /** * Gets the `ChatManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatManager` class. */ get chatManager(): ChatManager; /** * Gets the `ChatGroupManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatGroupManager` class. */ get groupManager(): ChatGroupManager; /** * Gets the `ChatContactManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatContactManager` class. */ get contactManager(): ChatContactManager; /** * Gets the `ChatPushManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatPushManager` class. */ get pushManager(): ChatPushManager; /** * Gets the `ChatUserInfoManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatUserInfoManager` class. */ get userManager(): ChatUserInfoManager; /** * Gets the `ChatRoomManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatRoomManager` class. */ get roomManager(): ChatRoomManager; /** * Gets the `ChatPresenceManager` class. Make sure to call it after ChatClient has been initialized. * * @returns The `ChatPresenceManager` class. */ get presenceManager(): ChatPresenceManager; }