agora_chat_SDK 1.0.6
agora java chat SDK
|
Classes | |
interface | AppStateListener |
interface | CheckResultListener |
class | MyConnectionListener |
class | MyMultiDeviceListener |
Public Member Functions | |
void | init (Context context, ChatOptions options) |
void | createAccount (String username, String password) throws ChatException |
void | login (String id, String password, final CallBack callback) throws IllegalArgumentException |
void | loginWithToken (String username, String token, final CallBack callback) |
void | loginWithAgoraToken (String username, String agoraToken, 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) |
GroupManager | groupManager () |
PushManager | pushManager () |
ChatRoomManager | chatroomManager () |
ChatManager | chatManager () |
UserInfoManager | userInfoManager () |
ContactManager | contactManager () |
TranslationManager | translationManager () |
PresenceManager | presenceManager () |
ChatThreadManager | chatThreadManager () |
Context | getContext () |
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) |
boolean | updateCurrentUserNick (String nickname) throws IllegalArgumentException, ChatException |
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 |
void | kickDevice (String username, String password, String resource) throws ChatException |
void | kickAllDevices (String username, String password) throws ChatException |
void | sendFCMTokenToServer (String fcmToken) |
void | sendHMSPushTokenToServer (String appId, String token) |
void | sendHMSPushTokenToServer (String token) |
boolean | isFCMAvailable () |
String | getAccessToken () |
boolean | isSdkInited () |
EMChatConfigPrivate | getChatConfigPrivate () |
JSONObject | getDeviceInfo () |
void | check (String username, String password, final CheckResultListener listener) |
Static Public Member Functions | |
static ChatClient | getInstance () |
Static Public Attributes | |
static final String | TAG = "ChatClient" |
static final String | VERSION = "1.0.6" |
The ChatClient, which is the entry point of the Chat SDK. You can log in, log out, and access other functionalities such as group and chatroom with this class.
void io.agora.chat.ChatClient.addConnectionListener | ( | final ConnectionListener | listener | ) |
Adds the connection listener of chat server.
listener | The chat server connection listener. ConnectionListener#onConnected() indicates a successful connection to chat server, ConnectionListener#onDisconnected(int) indicates a failure connection to chat server, it contains the error code, see Error. |
void io.agora.chat.ChatClient.addMultiDeviceListener | ( | MultiDeviceListener | listener | ) |
Adds the multi-device listener.
listener | See MultiDeviceListener, MultiDeviceListener#onContactEvent(int, String, String) is the contact event callback, MultiDeviceListener#onGroupEvent(int, String, List) is the group event callback. |
void io.agora.chat.ChatClient.changeAppkey | ( | String | appkey | ) | throws ChatException |
Update the App Key, which is the unique identifier used to access Agora Chat.
You retrieve the new App Key from Agora Console.
As this key controls all access to Agora Chat 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 ChatOptions#setAppKey(String).
appkey | The App Key, make sure to set the param. |
ChatManager io.agora.chat.ChatClient.chatManager | ( | ) |
Gets the ChatManager
class. Make sure to call it after ChatClient has been initialized, see init(Context, ChatOptions)
ChatManager
class. ChatRoomManager io.agora.chat.ChatClient.chatroomManager | ( | ) |
Gets the ChatRoomManager
class. Make sure to call it after the ChatClient has been initialized, see init(Context, ChatOptions).
ChatRoomManager
class. ChatThreadManager io.agora.chat.ChatClient.chatThreadManager | ( | ) |
Gets the ChatThreadManager
class. Make sure to call it after ChatClient has been initialized, see init(Context, ChatOptions).
ChatThreadManager
class. void io.agora.chat.ChatClient.check | ( | String | username, |
String | password, | ||
final CheckResultListener | listener | ||
) |
The service check interface. The schedule is as follows:
1.Validates the username and password user input. 2.Gets the dns list from the server. 3.Gets the token from the server. 4.Connects to the im server. 5.Logout.(If you call this method after the user logged in, this step will not be in the schedule.)
If there is a error occurs during checking, this schedule will be interrupted.
username | The user inputted for service check. If account has logged in before, this username would be changed to the logged in username to avoid update the current logged in account data. |
password | The password for username. if this is a logged in service check, the password would changed to the logged in password. |
listener | A listener for service check results 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 into a gzip archive. Best practice is to delete this debug archive as soon as it is no longer used.
ChatException | A description of the cause of the exception if the method fails. |
ContactManager io.agora.chat.ChatClient.contactManager | ( | ) |
Gets the ContactManager
class. Make sure to call it after the ChatClient has been initialized, see init(Context, ChatOptions).
ContactManager
class. void io.agora.chat.ChatClient.createAccount | ( | String | username, |
String | password | ||
) | throws ChatException |
Register a new user with your chat network.
This is a synchronous method and blocks the current thread.
username | The username. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
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 attachment (voice, image, file and so on), the token should be added to the request header;
The SDK returns null when any exceptions occurs.
You can detect whether there is a exception by check the token. If the token is null, you can check the EMLog file to find the exception.
You can also get token by calling ChatOptions#getAccessToken(boolean) and enter true.
synchronized String io.agora.chat.ChatClient.getCurrentUser | ( | ) |
Gets the current login user ID.
List< DeviceInfo > io.agora.chat.ChatClient.getLoggedInDevicesFromServer | ( | String | username, |
String | password | ||
) | throws ChatException |
Gets all the information about the logged in devices under the specified account.
This is a synchronous method and blocks the current thread.
username | The user ID you want to get the device information. |
password | The password. |
ChatException | A description of the exception, see Error. |
ChatOptions io.agora.chat.ChatClient.getOptions | ( | ) |
Gets ChatOptions.
void io.agora.chat.ChatClient.getUserTokenFromServer | ( | final String | username, |
final String | password, | ||
final ValueCallBack< String > | callBack | ||
) |
Fetches token by username and password.
username | The registered username. |
password | The password. |
callBack | The result callbackļ¼
|
GroupManager io.agora.chat.ChatClient.groupManager | ( | ) |
Gets the GroupManager
class. Be sure to call it after the ChatClient has been 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 | Make sure to set the param. |
options | The configurations. Make sure to set the param, see ChatOptions. |
boolean io.agora.chat.ChatClient.isConnected | ( | ) |
Checks whether the SDK is connected to the chat server.
true
means that the SDK is connected to the chat server.false
means not. boolean io.agora.chat.ChatClient.isFCMAvailable | ( | ) |
Checks whether the FCM push is available.
true
: the FCM push is available;false
: not available. boolean io.agora.chat.ChatClient.isLoggedIn | ( | ) |
Checks whether the user is logged in.
true
indicates that the user has logged in;false
indicates not. boolean io.agora.chat.ChatClient.isLoggedInBefore | ( | ) |
Checks whether the user has logged in before and did not log out.
Reference: If you need to check whether the SDK is connected to the server, please use isConnected().
true
means that the user has logged in before,false
means that the user has not login before or has called logout() method. boolean io.agora.chat.ChatClient.isSdkInited | ( | ) |
Checks whether the SDK has been initialized.
true
: The SDK has been initialized.false
: The SDK has not been initialized. void io.agora.chat.ChatClient.kickAllDevices | ( | String | username, |
String | password | ||
) | throws ChatException |
Kicks out all the devices logged in under the specified account.
This is a synchronous method and blocks the current thread.
username | The account you want to log out from all the devices. |
password | The account's password. |
ChatException | A description of the exception, see Error. |
void io.agora.chat.ChatClient.kickDevice | ( | String | username, |
String | password, | ||
String | resource | ||
) | throws ChatException |
Force the specified account to logout from the specified device, to fetch the device ID: DeviceInfo#getResource().
This is a synchronous method and blocks the current thread.
username | The account you want to force logout. |
password | The account's 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.login | ( | String | id, |
String | password, | ||
final CallBack | callback | ||
) | throws IllegalArgumentException |
An app user logs in to the chat server with a password.
Reference: An app user logs in to to the chat server by user ID and token, see loginWithToken(String, String, CallBack).
This is an asynchronous method.
id | The unique chat user ID, the same as username. Make sure to set the param. |
password | The password. Make sure to set the param. |
callback | The login callback. Make sure to set the param. The result is returned via the callback. |
IllegalArgumentException | A description of the issue that caused this call to fail. For example, the user ID, password, callback or App Key is null. |
void io.agora.chat.ChatClient.loginWithAgoraToken | ( | String | username, |
String | agoraToken, | ||
final CallBack | callback | ||
) |
An app user logs in to the chat server by user ID and Agora token. This method supports automatic login.
Reference: Another method to login to chat server is to login with user ID and token, see login(String, String, CallBack).
This an asynchronous method.
username | The user ID. Make sure to set the param. |
agoraToken | The Agora token. Make sure to set the param. |
callback | The callback. Make sure to set the param. The result of login is returned via the callback. |
RuntimeException | If the App Key is null, the SDK will throws a RuntimeException. |
IllegalArgumentException | A description of the exception. For example, the user ID, AgoraToken or callback is null. |
void io.agora.chat.ChatClient.loginWithToken | ( | String | username, |
String | token, | ||
final CallBack | callback | ||
) |
An app user logs in to the chat server by user ID and token.
Reference: There is another method to login to the chat server, which is by user ID and password, see login(String, String, CallBack).
This is an asynchronous method.
username | The user ID. Make sure to set the param. |
token | The password for this user ID. Make sure to set the param. |
callback | The login callback. Make sure to set the param. The result of login is returned via the callback. |
RuntimeException | If the app key is null, the SDK throws a RuntimeException. |
IllegalArgumentException | A description of the issue that caused this call to fail. For example, the ID, token or callback is null. |
int io.agora.chat.ChatClient.logout | ( | boolean | unbindToken | ) |
An app user logs out and returns the result.
This is a synchronous method and blocks the current thread.
unbindToken | Whether to unbind the token.
|
void io.agora.chat.ChatClient.logout | ( | final boolean | unbindToken, |
final CallBack | callback | ||
) |
An app user logs out the chat server.
This is an asynchronous method.
unbindToken | Whether to unbind token.
|
callback | The completion callback, which contains the error message if the method fails. |
void io.agora.chat.ChatClient.notifyTokenExpired | ( | String | response | ) |
The notification that the token is expired, will be called back to the connectionListener expiration event through ChatClient.
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. Be sure to call it after the ChatClient has been initialized, see init(Context, ChatOptions).
PushManager
class. void io.agora.chat.ChatClient.removeConnectionListener | ( | final ConnectionListener | listener | ) |
Removes the chat server connection listener.
listener | The chat server connection listener. |
void io.agora.chat.ChatClient.removeMultiDeviceListener | ( | MultiDeviceListener | listener | ) |
Removes the multi-device listener.
listener | See MultiDeviceListener. |
void io.agora.chat.ChatClient.renewToken | ( | String | newAgoraToken | ) |
When a user is in the Agora token login state and receives a callback notification of the token is to be expired in the ConnectionListener implementation class, this API can be called to update the token to avoid unknown problems caused by the token invalidation.
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 all the following conditions are met: 1.The token is not empty; 2.The user have logged in; 3.The device support Google PUSH service; 4.The push type is FCM io.agora.push.PushType#FCM.
You can set with ChatOptions#setFCMNumber(String).
fcmToken | The token you want to upload. |
void io.agora.chat.ChatClient.sendHMSPushTokenToServer | ( | String | appId, |
String | token | ||
) |
Sends the Huawei devices token to the server.
appId | The Huawei appId. |
token | The Huawei device token. @Deprecated Please use sendHMSPushTokenToServer(String) instead. |
void io.agora.chat.ChatClient.sendHMSPushTokenToServer | ( | String | token | ) |
Sends the Huawei devices token to the server.
token | The Huawei device token. |
void io.agora.chat.ChatClient.setDebugMode | ( | boolean | debugMode | ) |
Sets whether to output the debug info. Make sure to call the method after the ChatClient has been initialized, see init(Context, ChatOptions).
The SDK will out put debug info if you set the debugMode as true
.
debugMode | - true : The SDK will output the debug info;
|
boolean io.agora.chat.ChatClient.updateCurrentUserNick | ( | String | nickname | ) | throws IllegalArgumentException, ChatException |
Updates the current user's push notification display nickname, which is used to display in the notification bar when pushing.
Notice that the nickname in user profiles is different from this PushNickname.
We recommend you to update the push notification display nickname to the chat server after getting the user information from the user server; When the nickname of user information change, make sure to update to the chat server to prevent display discrepancies.
nickname | Make sure to set the param, the data length is not more than 100 characters. |
void io.agora.chat.ChatClient.uploadLog | ( | CallBack | callback | ) |
Uploads local log file.
The information in the debug log is used by 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. Make sure to call it after ChatClient has been initialized, see init(Context, ChatOptions).
UserInfoManager
class.