Chat SDK for Android v1.2.1
agora java chat SDK
|
Public Member Functions | |
void | init (Context context, ChatOptions options) |
void | createAccount (String username, String password) throws ChatException |
void | login (String id, String password, @NonNull final CallBack callback) |
void | loginWithToken (String username, String token, @NonNull final CallBack callback) |
void | loginWithAgoraToken (String username, String agoraToken, @NonNull final CallBack callback) |
void | notifyTokenExpired (String response) |
void | renewToken (String newAgoraToken) |
int | logout (boolean unbindToken) |
void | logout (final boolean unbindToken, final CallBack callback) |
void | changeAppkey (String appkey) throws ChatException |
void | addConnectionListener (final ConnectionListener listener) |
void | removeConnectionListener (final ConnectionListener listener) |
void | addLogListener (final ChatLogListener listener) |
void | removeLogListener (final ChatLogListener listener) |
GroupManager | groupManager () |
PushManager | pushManager () |
ChatRoomManager | chatroomManager () |
ChatManager | chatManager () |
UserInfoManager | userInfoManager () |
ContactManager | contactManager () |
ChatThreadManager | chatThreadManager () |
synchronized String | getCurrentUser () |
void | getUserTokenFromServer (final String username, final String password, final ValueCallBack< String > callBack) |
boolean | isLoggedInBefore () |
boolean | isConnected () |
boolean | isLoggedIn () |
void | setDebugMode (boolean debugMode) |
void | uploadLog (CallBack callback) |
ChatOptions | getOptions () |
String | compressLogs () throws ChatException |
void | addMultiDeviceListener (MultiDeviceListener listener) |
void | removeMultiDeviceListener (MultiDeviceListener listener) |
List< DeviceInfo > | getLoggedInDevicesFromServer (String username, String password) throws ChatException |
List< DeviceInfo > | getLoggedInDevicesFromServerWithToken (@NonNull String username, @NonNull String token) throws ChatException |
void | kickDevice (String username, String password, String resource) throws ChatException |
void | kickDeviceWithToken (@NonNull String username, @NonNull String token, String resource) throws ChatException |
void | kickAllDevices (String username, String password) throws ChatException |
void | kickAllDevicesWithToken (@NonNull String username, @NonNull String token) throws ChatException |
void | sendFCMTokenToServer (String fcmToken) |
void | sendHMSPushTokenToServer (String token) |
void | sendHonorPushTokenToServer (String token) |
boolean | isFCMAvailable () |
String | getAccessToken () |
boolean | isSdkInited () |
void | check (String username, String password, final CheckResultListener listener) |
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 io.agora.chat.ChatClient.addConnectionListener | ( | final ConnectionListener | 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 io.agora.chat.ChatClient.addLogListener | ( | final ChatLogListener | listener | ) |
Adds the log callback listener of SDK.
listener | The log callback listener, ChatLogListener#onLog(String). |
void io.agora.chat.ChatClient.addMultiDeviceListener | ( | MultiDeviceListener | listener | ) |
Adds the multi-device listener.
listener | The multi-device listener to add. See MultiDeviceListener. MultiDeviceListener#onContactEvent(int, String, String) is the contact event callback and MultiDeviceListener#onGroupEvent(int, String, List) is the group event callback. |
void io.agora.chat.ChatClient.changeAppkey | ( | String | appkey | ) | throws ChatException |
Update the App Key.
Note
appkey | The App Key, make sure to set the param. |
ChatManager io.agora.chat.ChatClient.chatManager | ( | ) |
Gets the ChatManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
ChatManager
class. ChatRoomManager io.agora.chat.ChatClient.chatroomManager | ( | ) |
Gets the ChatRoomManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
ChatRoomManager
class. ChatThreadManager io.agora.chat.ChatClient.chatThreadManager | ( | ) |
Gets the ChatThreadManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
ChatThreadManager
class. void io.agora.chat.ChatClient.check | ( | String | username, |
String | password, | ||
final CheckResultListener | listener | ||
) |
Checks the Chat service.
The service check process is as follows:
If an error occurs during the check, the check process will be interrupted.
username | The user ID for the service check. If a user account has logged in before, this user ID will be changed to the logged-in user ID to avoid changes to the information of the current logged-in user account. |
password | The password. If a user account has logged in before, the password will be changed to the password of the logged-in user. |
listener | The service check result callback. |
Contains account-validation check, get-dns check, get-Token check, login check. So the EMAChatClient.CheckResultListener#onResult(int, int, String) callback will be called four times.
String io.agora.chat.ChatClient.compressLogs | ( | ) | throws ChatException |
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.
ChatException | A description of the cause of the exception if the method fails. |
ContactManager io.agora.chat.ChatClient.contactManager | ( | ) |
Gets the ContactManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
ContactManager
class. void io.agora.chat.ChatClient.createAccount | ( | String | username, |
String | password | ||
) | throws ChatException |
Adds a new user account.
This method is not recommended and you are advised to call the RESTful API.
This is a synchronous method and blocks the current thread.
username | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. The user ID can contain characters of the following types:
|
password | The password. The maximum length is 64 characters. Ensure that you set this parameter. |
ChatException | A description of the issue that caused this call to fail. For example, the user account or password is null, or the account is illegal. |
String io.agora.chat.ChatClient.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 ChatOptions#getAccessToken(boolean) and passing true
.
synchronized String io.agora.chat.ChatClient.getCurrentUser | ( | ) |
Gets the user ID of the current logged-in user.
List< DeviceInfo > io.agora.chat.ChatClient.getLoggedInDevicesFromServer | ( | String | username, |
String | password | ||
) | throws ChatException |
Gets the list of online devices to which you have logged in with a specified account.
This is a synchronous method and blocks the current thread.
username | The user ID. |
password | The password. |
ChatException | A description of the exception, see Error. |
List< DeviceInfo > io.agora.chat.ChatClient.getLoggedInDevicesFromServerWithToken | ( | @NonNull String | username, |
@NonNull String | token | ||
) | throws ChatException |
Gets the list of online devices to which you have logged in with a specified account.
This is a synchronous method and blocks the current thread.
username | The user ID. |
token | The token. |
ChatException | A description of the exception, see Error. |
ChatOptions io.agora.chat.ChatClient.getOptions | ( | ) |
Gets configuration options of the SDK.
void io.agora.chat.ChatClient.getUserTokenFromServer | ( | final String | username, |
final String | password, | ||
final ValueCallBack< String > | callBack | ||
) |
Get a token by using the user ID and password.
username | The user ID. |
password | The password. |
callBack | The result callbackļ¼
|
GroupManager io.agora.chat.ChatClient.groupManager | ( | ) |
Gets the GroupManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
GroupManager
class. void io.agora.chat.ChatClient.init | ( | Context | context, |
ChatOptions | 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 ChatOptions. |
boolean io.agora.chat.ChatClient.isConnected | ( | ) |
Checks whether the SDK is connected to the chat server.
true
: Yes;false
: No. boolean io.agora.chat.ChatClient.isFCMAvailable | ( | ) |
Checks whether the FCM push is available.
true
: Yes;false
: No. boolean io.agora.chat.ChatClient.isLoggedIn | ( | ) |
Checks whether the user has logged in to the Chat app.
true
: Yes;false
: No. boolean io.agora.chat.ChatClient.isLoggedInBefore | ( | ) |
Checks whether the user has logged in before.
This method always returns true
if you log in successfully and have not called the logout() method yet.
If you need to check whether the SDK is connected to the server, call isConnected().
true
: The user has logged in before;false
: The user has not logged in before or has called the logout() method. boolean io.agora.chat.ChatClient.isSdkInited | ( | ) |
Checks whether the SDK is initialized.
true
: Yes.false
: No. void io.agora.chat.ChatClient.kickAllDevices | ( | String | username, |
String | password | ||
) | throws ChatException |
Logs out from a specified account on all devices.
This is a synchronous method and blocks the current thread.
username | The user ID. |
password | The password. |
ChatException | A description of the exception, see Error. |
void io.agora.chat.ChatClient.kickAllDevicesWithToken | ( | @NonNull String | username, |
@NonNull String | token | ||
) | throws ChatException |
Logs out from a specified account on all devices.
This is a synchronous method and blocks the current thread.
username | The user ID. |
token | The token. |
ChatException | A description of the exception, see Error. |
void io.agora.chat.ChatClient.kickDevice | ( | String | username, |
String | password, | ||
String | resource | ||
) | throws ChatException |
Logs out from a specified account on a device.
You can call DeviceInfo#getResource() to get the device ID.
This is a synchronous method and blocks the current thread.
username | The user ID. |
password | The password. |
resource | The device ID. See DeviceInfo#getResource(). |
ChatException | A description of the exception if the method fails, see Error. |
void io.agora.chat.ChatClient.kickDeviceWithToken | ( | @NonNull String | username, |
@NonNull String | token, | ||
String | resource | ||
) | throws ChatException |
Logs out from a specified account on a device.
You can call DeviceInfo#getResource() to get the device ID.
This is a synchronous method and blocks the current thread.
username | The user ID. |
token | The token. |
resource | The device ID. See DeviceInfo#getResource(). |
ChatException | A description of the exception if the method fails, see Error. |
void io.agora.chat.ChatClient.login | ( | String | id, |
String | password, | ||
@NonNull final CallBack | callback | ||
) |
Logs in to the chat server with a password.
Also, you can call loginWithToken(String, String, CallBack) to log in to the chat server with the user ID and token.
This is an asynchronous method.
id | The unique chat user ID. Make sure to set the parameter. |
password | The password. Make sure to set the parameter. |
callback | The login callback. Make sure to set the parameter. The login result is returned via the callback. |
void io.agora.chat.ChatClient.loginWithAgoraToken | ( | String | username, |
String | agoraToken, | ||
@NonNull final CallBack | callback | ||
) |
Logs in to the chat server with the user ID and Agora token.
This method supports automatic login.
An app user can also log in to the chat server with the user ID and token. See login(String, String, CallBack).
This an asynchronous method.
username | The user ID. Make sure to set the parameter. |
agoraToken | The Agora token. Make sure to set the parameter. |
callback | The login callback. Make sure to set the parameter. The result of login is returned via the callback. |
void io.agora.chat.ChatClient.loginWithToken | ( | String | username, |
String | token, | ||
@NonNull final CallBack | callback | ||
) |
Logs in to the chat server with the user ID and token.
This method supports automatic login.
You can also call login(String, String, CallBack) to log in to the chat server with the user ID and password.
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 io.agora.chat.ChatClient.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.
|
void io.agora.chat.ChatClient.logout | ( | final boolean | unbindToken, |
final CallBack | 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 io.agora.chat.ChatClient.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. |
PushManager io.agora.chat.ChatClient.pushManager | ( | ) |
Gets the PushManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
PushManager
class. void io.agora.chat.ChatClient.removeConnectionListener | ( | final ConnectionListener | listener | ) |
Removes the connection status listener.
listener | The connection status listener to remove. |
void io.agora.chat.ChatClient.removeLogListener | ( | final ChatLogListener | listener | ) |
Removes the log callback listener.
listener | The log callback listener. |
void io.agora.chat.ChatClient.removeMultiDeviceListener | ( | MultiDeviceListener | listener | ) |
Removes the multi-device listener.
listener | The multi-device listener to remove. See MultiDeviceListener. |
void io.agora.chat.ChatClient.renewToken | ( | String | newAgoraToken | ) |
Renews the Agora token.
If you log in with an Agora token and are notified by a callback method ConnectionListener 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.
newAgoraToken | The new token. |
void io.agora.chat.ChatClient.sendFCMTokenToServer | ( | String | fcmToken | ) |
Uploads the FCM token to the chat server.
The token can be uploaded when the following conditions are met:
fcmToken | The token to upload. |
void io.agora.chat.ChatClient.sendHMSPushTokenToServer | ( | String | token | ) |
Sends the HUAWEI Push token to the server.
token | The Huawei Push token. |
void io.agora.chat.ChatClient.sendHonorPushTokenToServer | ( | String | token | ) |
Sends the Honor Push token to the server.
token | The Honor Push token. |
void io.agora.chat.ChatClient.setDebugMode | ( | boolean | debugMode | ) |
Sets whether to output the debug information.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
debugMode | Whether to output the debug information:
|
void io.agora.chat.ChatClient.uploadLog | ( | CallBack | 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. |
UserInfoManager io.agora.chat.ChatClient.userInfoManager | ( | ) |
Gets the UserInfoManager
class.
This method can be called only after the ChatClient is initialized. See init(Context, ChatOptions).
UserInfoManager
class.