import { NativeEventEmitter } from 'react-native'; import { BaseManager } from './__internal__/Base'; import { ChatContactManager } from './ChatContactManager'; import { type ChatConnectEventListener, type ChatCustomEventListener, type ChatExceptionEventListener, type 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 { ChatOptions } from './common/ChatOptions'; import { ChatRTCTokenInfo } from './common/ChatRTCTokenInfo'; /** * The chat client class, which is the entry of the chat SDK. It defines how to log in to and log out of the chat app and how to manage the connection between the SDK and the chat server. */ export declare class ChatClient extends BaseManager { static eventType: number; protected static TAG: string; private static _instance; private _connectionSubscriptions; static getInstance(): ChatClient; private setEventEmitter; getEventEmitter(): NativeEventEmitter; private _chatManager; private _groupManager; private _contactManager; private _chatRoomManager; private _pushManager; private _userInfoManager; private _presenceManager; private _connectionListeners; private _multiDeviceListeners; private _customListeners; private _options?; private readonly _rnSdkVersion; private _currentUsername; private constructor(); setNativeListener(event: NativeEventEmitter): void; private onConnected; private onDisconnected; private onTokenWillExpire; private onTokenDidExpire; private onMultiDeviceEvent; private onCustomEvent; private onOfflineMessageSyncStart; private onOfflineMessageSyncFinish; private onDataSyncStart; private onDataSyncFinish; private onDatabaseOpened; private reset; get version(): string; /** * Gets the SDK configurations. * * Ensure that you set the SDK options during initialization. See {@link ChatOptions}. * * @returns The SDK configurations. */ get options(): ChatOptions | undefined; /** * 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 {@link getCurrentUsername} to get the latest data from the server. * * @returns The current logged-in user ID. */ get currentUserName(): string; /** * 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. * * @param options The options for SDK initialization. Ensure that you set the options. 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. * * **Note** * * To get the current logged-in user ID from the memory, see {@link currentUserName}. * * @returns The logged-in user ID. * * @throws A description of the exception. See {@link ChatError}. */ getCurrentUsername(): Promise; /** * Gets the token for login. * * @returns The token for login. * * @throws A description of the exception. See {@link ChatError}. */ getAccessToken(): Promise; /** * Logs in to the chat server with a token. An exception message is thrown if the login fails. * * **Note** * * If you use a token to log in to the server, you can get the token in either of the following ways: * - Through the console. * * The token expiration reminder is returned by the two callback methods: {@link ChatConnectEventListener.onTokenWillExpire} and {@link ChatConnectEventListener.onTokenDidExpire}. * * @param userId The user ID. * @param token The token. * * @throws A description of the exception. See {@link ChatError}. */ loginWithToken(userId: string, token: string): Promise; /** * Renews the token. * * **Note** * * If you log in with a token and are notified by the callback method {@link 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. * * @param token The new token. * * @throws A description of the exception. See {@link ChatError}. */ renewToken(token: string): Promise; /** * Logs out of the chat app. An exception message is thrown if the logout fails. * * @param unbindDeviceToken Whether to unbind the token upon logout. This parameter is available only to mobile platforms. * - (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 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 {@link ChatOptions.appKey} method when logged out. * * @param newAppKey The new App Key. Ensure that you set this parameter. * * @throws A description of the exception. See {@link ChatError}. */ changeAppKey(newAppKey: string): Promise; /** * Updates the App id, which is the unique identifier used to access the chat service. * * **Note** * * - As this id controls access to the chat service for your app, you can only update the id when the current user is logged out. * * - Updating the App id means to switch to a new App id. * * - You can retrieve the new App id from the Console. * * - You can also set an App id by using the {@link ChatOptions.appId} method when logged out. * * @param newAppId The new App id. Ensure that you set this parameter. * * @throws A description of the exception. See {@link ChatError}. */ changeAppId(newAppId: string): Promise; /** * Compresses the debug log file into a gzip archive. * * We strongly 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 the list of online devices to which you have logged in with a specified account. * * @param userId The user ID. * @param token The user token. See {@link getAccessToken}. * @returns The list of the online logged-in devices. * * @throws A description of the exception. See {@link ChatError}. */ getLoggedInDevicesFromServer(userId: string, token: string): Promise>; /** * Logs out from a specified account on a device. * * For how to get the device ID, see {@link ChatDeviceInfo.resource}. * * @param userId The user ID. * @param token The user token. See {@link getAccessToken}. * @param resource The device ID. See {@link ChatDeviceInfo.resource}. * * @throws A description of the exception. See {@link ChatError}. */ kickDevice(userId: string, token: string, resource: string): Promise; /** * Logs out from a specified account on all devices. * * @param userId The user ID. * @param token The user token. See {@link getAccessToken}. * * @throws A description of the exception. See {@link ChatError}. */ kickAllDevices(userId: string, token: string): Promise; /** * Binds the push token of the device. * * @param params * - deviceToken: The push token reported by the push service of the platform. * - notifierName: The push credential of the platform. This parameter is required on Android and is ignored on iOS. * - Android: The vendor push credential, for example the FCM Sender ID, the HUAWEI/Honor app ID, the Xiaomi/Meizu app ID, the OPPO app key, or the vivo `appId#appKey`. It must not be empty, otherwise the native SDK returns an invalid-parameter error. * - iOS: Not used. Set the APNs certificate name with {@link ChatOptions.apnsCertName} when the SDK is initialized, because the certificate name cannot be changed during the app runtime. * * @throws A description of the exception. See {@link ChatError}. */ bindDeviceToken(params: { deviceToken: string; notifierName?: string; }): Promise; /** * Binds the Apple PushKit token, which is used for VoIP push notifications. * * **Note** This method is available only on the iOS platform; calling it on other platforms does nothing. * * @param params * - deviceToken: The PushKit token reported by `PKPushRegistry`, in hexadecimal. * * **Note** The PushKit certificate name must be set with {@link ChatOptions.pushKitCertName} when the SDK is initialized, because the certificate name cannot be changed during the app runtime. * * **Note** The native SDK caches the token before binding it: if the current user has not logged in, this call fails with {@link ChatError}, but the token stays cached and is bound automatically after the next successful login. {@link ChatClient.logout} with `unbindDeviceToken` set to `true` unbinds the PushKit token as well. * * @throws A description of the exception. See {@link ChatError}. */ bindPushKitToken(params: { deviceToken: string; }): Promise; /** * Unbinds the Apple PushKit token bound by {@link ChatClient.bindPushKitToken}. * * **Note** This method is available only on the iOS platform; calling it on other platforms does nothing. * * {@link ChatClient.logout} with `unbindDeviceToken` set to `true` already unbinds the PushKit token, so call this method only when you need to unbind it while the current user stays logged in. * * @throws A description of the exception. See {@link ChatError}. */ unbindPushKitToken(): Promise; /** * Gets the Agora RTC token, token expiration time, and RTC UID matching the Agora Chat user ID according to the channel name (channelName). * * You must enable the Agora RTC feature before calling this API. * * If the channel name is set to null, an RTC token valid for all channels will be generated. * * This is an asynchronous method. * * @param channelName The Agora RTC channel name. * @returns The RTC token information. See {@link ChatRTCTokenInfo}. * * @throws A description of the exception. See {@link ChatError}. */ getRTCTokenInfoWithChannelName(channelName: string): Promise; /** * Gets the Agora Chat user IDs matching the Agora RTC UIDs. * * @param ids The Agora RTC UID list. * @returns The map of Agora RTC UIDs and Agora Chat user IDs. * * @throws A description of the exception. See {@link ChatError}. */ getUserIdsWithRTCUids(ids: Array): Promise>; /** * Adds the connection status listener. * * @param listener The connection status listener to add. */ addConnectionListener(listener: ChatConnectEventListener): void; /** * Removes the connection status listener. * * @param listener The connection status listener to remove. */ removeConnectionListener(listener: ChatConnectEventListener): void; /** * Removes all the connection status listeners for the chat server. */ removeAllConnectionListener(): void; /** * Adds the multi-device listener. * * @param listener The multi-device listener to add. */ addMultiDeviceListener(listener: ChatMultiDeviceEventListener): void; /** * Removes the specified multi-device listener. * * @param listener The multi-device listener to remove. */ removeMultiDeviceListener(listener: ChatMultiDeviceEventListener): void; /** * Removes all the multi-device listeners. */ removeAllMultiDeviceListener(): void; /** * Adds a custom listener to receive data that the iOS or Android devices send to the React Native layer. * * @param listener The custom listener to add. */ addCustomListener(listener: ChatCustomEventListener): void; /** * Removes a custom listener to stop receiving data that the iOS or Android devices send to the React Native layer. * * @param listener The custom listener to remove. */ removeCustomListener(listener: ChatCustomEventListener): void; /** * Removes all the custom listeners. */ removeAllCustomListener(): void; /** * Add error listener. * * Monitor SDK internal errors. */ addExceptListener(listener: ChatExceptionEventListener): void; /** * Remove error listener. */ removeExceptListener(listener: ChatExceptionEventListener): void; /** * Remove all error listener. */ removeAllExceptListener(): void; /** * Gets the chat manager class. * * This method can be called only after the chat client is initialized. * * @returns The chat manager class. */ get chatManager(): ChatManager; /** * Gets the chat group manager class. * * This method can be called only after the chat client is initialized. * * @returns The chat group manager class. */ get groupManager(): ChatGroupManager; /** * Gets the contact manager class. * * This method can be called only after the chat client is initialized. * * @returns The contact manager class. */ get contactManager(): ChatContactManager; /** * Gets the push manager class. * * This method can be called only after the chat client is initialized. * * @returns The push manager class. */ get pushManager(): ChatPushManager; /** * Gets the user information manager class. * * This method can be called only after the chat client is initialized. * * @returns The user information manager class. */ get userManager(): ChatUserInfoManager; /** * Gets the chat room manager class. * * This method can be called only after the chat client is initialized. * * @returns The chat room manager class. */ get roomManager(): ChatRoomManager; /** * Gets the presence manager class. * * This method can be called only after the chat client is initialized. * * @returns The presence manager class. */ get presenceManager(): ChatPresenceManager; } //# sourceMappingURL=ChatClient.d.ts.map