Public Member Functions | |
| synchronized void | init (Context context, EMOptions options) |
| void | loginWithToken (String username, String token, @NonNull final EMCallBack callback) |
| void | notifyTokenExpired (String response) |
| void | renewToken (String newToken, @NonNull EMCallBack callback) |
| int | logout (boolean unbindToken) |
| void | logout (final boolean unbindToken, final EMCallBack callback) |
| void | changeAppkey (String appkey) throws HyphenateException |
| void | changeAppId (String appId) throws HyphenateException |
| void | addConnectionListener (final EMConnectionListener listener) |
| void | removeConnectionListener (final EMConnectionListener listener) |
| void | addLogListener (final EMLogListener listener) |
| void | removeLogListener (final EMLogListener listener) |
| EMGroupManager | groupManager () |
| EMPushManager | pushManager () |
| EMChatRoomManager | chatroomManager () |
| EMChatManager | chatManager () |
| EMUserInfoManager | userInfoManager () |
| EMContactManager | contactManager () |
| EMChatThreadManager | chatThreadManager () |
| synchronized String | getCurrentUser () |
| boolean | isConnected () |
| boolean | isLoggedIn () |
| void | setDebugMode (boolean debugMode) |
| void | uploadLog (EMCallBack callback) |
| EMOptions | getOptions () |
| String | compressLogs () throws HyphenateException |
| void | addMultiDeviceListener (EMMultiDeviceListener listener) |
| void | removeMultiDeviceListener (EMMultiDeviceListener listener) |
| void | fetchLoggedInDevicesFromServerWithToken (@NonNull String username, @NonNull String token, EMValueCallBack< List< EMDeviceInfo > > callBack) |
| void | kickDeviceWithToken (@NonNull String username, @NonNull String token, String resource) throws HyphenateException |
| void | kickAllDevicesWithToken (@NonNull String username, @NonNull String token) throws HyphenateException |
| void | sendFCMTokenToServer (String fcmToken) |
| void | sendHMSPushTokenToServer (String token) |
| void | sendHonorPushTokenToServer (String token) |
| boolean | isFCMAvailable () |
| String | getAccessToken () |
| boolean | isSdkInited () |
| boolean | isDatabaseOpened () |
| void | asyncGetRTCTokenInfoWithChannelName (@Nullable String channelName, EMValueCallBack< EMRTCTokenInfo > callBack) |
| void | asyncGetUserIdsWithRTCUids (List< Integer > uIds, EMValueCallBack< Map< Integer, String > > callBack) |
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.
| void com.hyphenate.chat.EMClient.addConnectionListener | ( | final EMConnectionListener | listener | ) |
Adds a connection status listener.
The listener listens for the connection between the chat app and the chat server.
| listener | The connection status listener to add.
|
| void com.hyphenate.chat.EMClient.addLogListener | ( | final EMLogListener | listener | ) |
Adds the log callback listener of SDK.
| listener | The log callback listener, EMLogListener#onLog(String). |
| void com.hyphenate.chat.EMClient.addMultiDeviceListener | ( | EMMultiDeviceListener | listener | ) |
Adds the multi-device listener.
| listener | The multi-device listener to add. See EMMultiDeviceListener. EMMultiDeviceListener#onContactEvent(int, String, String) is the contact event callback and EMMultiDeviceListener#onGroupEvent(int, String, List) is the group event callback. |
| void com.hyphenate.chat.EMClient.asyncGetRTCTokenInfoWithChannelName | ( | @Nullable String | channelName, |
| EMValueCallBack< EMRTCTokenInfo > | callBack ) |
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.
| channelName | The Agora RTC channel name. |
| callBack | The completion callback, which contains the RTC token, expiration time, and RTC UID. The error message is returned if this call fails. |
| void com.hyphenate.chat.EMClient.asyncGetUserIdsWithRTCUids | ( | List< Integer > | uIds, |
| EMValueCallBack< Map< Integer, String > > | callBack ) |
Gets the Agora Chat user IDs matching the Agora RTC UIDs.
This is an asynchronous method.
| uIds | The Agora RTC UID list. |
| callBack | The completion callback, which contains the mapping between the Agora RTC UIDs and Agora Chat user IDs. The error message is returned if the method call fails. |
| void com.hyphenate.chat.EMClient.changeAppId | ( | String | appId | ) | throws HyphenateException |
Updates the App ID.
EMOptions#setAppId(String) when you log out of the chat service.| appId | The unique identifier of the application, which cannot be empty. |
| void com.hyphenate.chat.EMClient.changeAppkey | ( | String | appkey | ) | throws HyphenateException |
Updates the App Key.
EMOptions#setAppKey(String) when you log out of the chat service.| appkey | The unique identifier of the application, which cannot be empty. |
| EMChatManager com.hyphenate.chat.EMClient.chatManager | ( | ) |
Gets the ChatManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
ChatManager class. | EMChatRoomManager com.hyphenate.chat.EMClient.chatroomManager | ( | ) |
Gets the ChatRoomManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
ChatRoomManager class. | EMChatThreadManager com.hyphenate.chat.EMClient.chatThreadManager | ( | ) |
Gets the EMChatThreadManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
EMChatThreadManager class. | String com.hyphenate.chat.EMClient.compressLogs | ( | ) | throws HyphenateException |
Compresses the debug log file into a gzip archive.
It is strongly recommended that you delete this debug archive as soon as this method is called.
| HyphenateException | A description of the cause of the exception if the method fails. |
| EMContactManager com.hyphenate.chat.EMClient.contactManager | ( | ) |
Gets the ContactManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
ContactManager class. | void com.hyphenate.chat.EMClient.fetchLoggedInDevicesFromServerWithToken | ( | @NonNull String | username, |
| @NonNull String | token, | ||
| EMValueCallBack< List< EMDeviceInfo > > | callBack ) |
Gets the list of online devices where a specified user is logged in.
This is an asynchronous method, which replaces the former synchronous method getLoggedInDevicesFromServerWithToken.
| username | The user ID. |
| token | The user token. |
| callBack | The completion callback. If this call succeeds, calls EMValueCallBack#onSuccess(Object) with the list of online devices where the specified user is logged in; if this call fails, calls EMValueCallBack#onError(int, String). |
| String com.hyphenate.chat.EMClient.getAccessToken | ( | ) |
Gets the access token from the memory.
When uploading or downloading an attachment (a voice, image, or file), you must add the token to the request header. The SDK returns null when any exception occurs.
If the token is null, you can check the EMLog file for the possible reason.
You can also get the token from the server by calling EMOptions#getAccessToken(boolean) and passing true.
| synchronized String com.hyphenate.chat.EMClient.getCurrentUser | ( | ) |
Gets the user ID of the current logged-in user.
| EMOptions com.hyphenate.chat.EMClient.getOptions | ( | ) |
Gets configuration options of the SDK.
| EMGroupManager com.hyphenate.chat.EMClient.groupManager | ( | ) |
Gets the GroupManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
GroupManager class. | synchronized void com.hyphenate.chat.EMClient.init | ( | Context | context, |
| EMOptions | options ) |
Initializes the SDK.
Make sure to initialize the SDK in the main thread.
| context | The context. Make sure to set the parameter. |
| options | The configuration options. Make sure to set the parameter. See EMOptions. |
| boolean com.hyphenate.chat.EMClient.isConnected | ( | ) |
Checks whether the SDK is connected to the chat server.
true: Yes;false: No. | boolean com.hyphenate.chat.EMClient.isDatabaseOpened | ( | ) |
Whether a usable local database context is currently available.
This state only indicates that the local database has been opened successfully and local database APIs can be used. It does not mean online login success and does not replace isLoggedIn() or connection-state callbacks.
| boolean com.hyphenate.chat.EMClient.isFCMAvailable | ( | ) |
Checks whether the FCM push is available.
true: Yes;false: No. | boolean com.hyphenate.chat.EMClient.isLoggedIn | ( | ) |
Checks whether the user has logged in to the Chat app.
true: Yes;false: No. | boolean com.hyphenate.chat.EMClient.isSdkInited | ( | ) |
Checks whether the SDK is initialized.
true: Yes.false: No. | void com.hyphenate.chat.EMClient.kickAllDevicesWithToken | ( | @NonNull String | username, |
| @NonNull String | token ) throws HyphenateException |
Kicks a user out of the app on all device.
This is a synchronous method and blocks the current thread.
| username | The user ID. |
| token | The user token. |
| HyphenateException | A description of the exception. See EMError. |
| void com.hyphenate.chat.EMClient.kickDeviceWithToken | ( | @NonNull String | username, |
| @NonNull String | token, | ||
| String | resource ) throws HyphenateException |
Kicks a user out of the app on a device.
You can call EMDeviceInfo#getResource() to get the device ID.
This is a synchronous method and blocks the current thread.
| username | The user ID. |
| token | The user token. |
| resource | The device ID. See EMDeviceInfo#getResource(). |
| HyphenateException | A description of the exception if the method fails. See EMError. |
| void com.hyphenate.chat.EMClient.loginWithToken | ( | String | username, |
| String | token, | ||
| @NonNull final EMCallBack | callback ) |
Logs in to the chat server with the user ID and token.
This is an asynchronous method.
| username | The user ID. Make sure to set the parameter. |
| token | The user token. Make sure to set this parameter. |
| callback | The login callback. Make sure to set the parameter. Also, this parameter cannot be null. The result of login is returned via the callback. |
| int com.hyphenate.chat.EMClient.logout | ( | boolean | unbindToken | ) |
Logs out of the chat app.
This is a synchronous method and blocks the current thread.
| unbindToken | Whether to unbind the token upon logout.
|
EMError#EM_NO_ERROR if the user successfully logs out;EMError. | void com.hyphenate.chat.EMClient.logout | ( | final boolean | unbindToken, |
| final EMCallBack | callback ) |
Logs out of the chat server.
This is an asynchronous method.
| unbindToken | Whether to unbind the token upon logout.
|
| callback | The completion callback, which contains the error message if the method call fails. |
| void com.hyphenate.chat.EMClient.notifyTokenExpired | ( | String | response | ) |
Notifies that the token expires.
The SDK triggers the token expiry notification callback via connectionListener.
| response | The request result, which includes the description of the issue that cause the method fails. |
| EMPushManager com.hyphenate.chat.EMClient.pushManager | ( | ) |
Gets the PushManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
PushManager class. | void com.hyphenate.chat.EMClient.removeConnectionListener | ( | final EMConnectionListener | listener | ) |
Removes the connection status listener.
| listener | The connection status listener to remove. |
| void com.hyphenate.chat.EMClient.removeLogListener | ( | final EMLogListener | listener | ) |
Removes the log callback listener.
| listener | The log callback listener. |
| void com.hyphenate.chat.EMClient.removeMultiDeviceListener | ( | EMMultiDeviceListener | listener | ) |
Removes the multi-device listener.
| listener | The multi-device listener to remove. See EMMultiDeviceListener. |
| void com.hyphenate.chat.EMClient.renewToken | ( | String | newToken, |
| @NonNull EMCallBack | callback ) |
Renews the Agora token.
If you log in with a token and are notified by a callback method EMConnectionListener 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.
| newToken | The new token. |
| callback | renew token callback. Make sure to set the parameter. The result of renew token is returned via the callback. |
| void com.hyphenate.chat.EMClient.sendFCMTokenToServer | ( | String | fcmToken | ) |
Uploads the FCM token to the chat server.
The token can be uploaded when the following conditions are met:
EMPushType#FCM.| fcmToken | The token to upload. |
| void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer | ( | String | token | ) |
Sends the HUAWEI Push token to the server.
| token | The Huawei Push token. |
| void com.hyphenate.chat.EMClient.sendHonorPushTokenToServer | ( | String | token | ) |
Sends the Honor Push token to the server.
| token | The Honor Push token. |
| void com.hyphenate.chat.EMClient.setDebugMode | ( | boolean | debugMode | ) |
Sets whether to output the debug information.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
| debugMode | Whether to output the debug information:
|
| void com.hyphenate.chat.EMClient.uploadLog | ( | EMCallBack | callback | ) |
Uploads local logs.
The debug logs provide reference for our engineers to fix errors and improve system performance.
This is a synchronous method and blocks the current thread.
| callback | Reserved parameter. |
| EMUserInfoManager com.hyphenate.chat.EMClient.userInfoManager | ( | ) |
Gets the EMUserInfoManager class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions). If the SDK is not initialized, it will return null.
EMUserInfoManager class.