agora_chat_SDK
3.8.2
agorajavachatSDK
|
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) |
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 () |
Context | getContext () |
synchronized String | getCurrentUser () |
void | getUserTokenFromServer (final String username, final String password, final ValueCallBack< String > callBack) |
boolean | isLoggedInBefore () |
boolean | isConnected () |
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 () |
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 = "3.8.2" |
Chat SDK Client, entrance of SDK, used to login, logout, and get access chat modules, such as
ChatManager chatManager = ChatClient.getInstance().chatManager();
void io.agora.chat.ChatClient.addConnectionListener | ( | final ConnectionListener | listener | ) |
Add chat server connection listener
listener | Chat server connection listener ConnectionListener#onConnected() indicates a successful connection to chat server ConnectionListener#onDisconnected(int) indicates a failure connection to chat server, the parameter means the error code, see Error |
void io.agora.chat.ChatClient.addMultiDeviceListener | ( | MultiDeviceListener | listener | ) |
add multiple devices 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 |
Change appkey Can ONLY be changed if not logged in Also can set appkey by ChatOptions#setAppKey(String), need be set if not logged in
appkey | Not be null or "" |
ChatManager io.agora.chat.ChatClient.chatManager | ( | ) |
Gets chat manager, calls it after ChatClient has been initialized, see init(Context, ChatOptions)
ChatRoomManager io.agora.chat.ChatClient.chatroomManager | ( | ) |
Gets chat room manager, calls it after ChatClient has been initialized, see init(Context, ChatOptions)
void io.agora.chat.ChatClient.check | ( | String | username, |
String | password, | ||
final CheckResultListener | listener | ||
) |
Service check interface, here is the schedule:
1.Validate the username and password user input. 2.Get dns list from server. 3.Get token from server. 4.Connect to the im server. 5.logout.(If call this method after user logged in, this step will not in schedule.)
If there is a error occurred during checking, this schedule will be broken.
username | 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 |
Compress log folder into zip file, return zip file path
ChatException | The exception by Compress gz file |
ContactManager io.agora.chat.ChatClient.contactManager | ( | ) |
Gets contact manager, calls it after ChatClient has been initialized, see init(Context, ChatOptions)
void io.agora.chat.ChatClient.createAccount | ( | String | username, |
String | password | ||
) | throws ChatException |
create an chat account on server
Synchronization method block the current thread
username | The account you want to register, not be null, can be a letter/number/underline/ cross/English period, regular as "^[a-zA-Z0-9_.-]+$", other is not allowed. It will automatically be converted to lowercase if it is a capital letter. The username's length can not be longer than 64 bytes. |
password | The password you want to register, not be null. The password's length can not be longer than 64 bytes. |
ChatException | If user account or password is null, or account is illegal will throw exception. The exception while registering account will be thrown here. |
String io.agora.chat.ChatClient.getAccessToken | ( | ) |
Gets access token from memory When uploading or downloading attachment (voice, image, file and so on), the token should be added to the request header; It is null when any exceptions occurs You can detect whether it is a problem by determining if the token is null. If the token is null, you can open the EMLog file to see the exception
Also can get token by ChatOptions#getAccessToken(). If you want to get token from server, can call ChatOptions#getAccessToken(boolean) and enter true
synchronized String io.agora.chat.ChatClient.getCurrentUser | ( | ) |
Gets 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
Synchronization method block the current thread
username | The account you want to get device info |
password | The account's password |
ChatException | 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 | ||
) |
Fetch token by username and password
username | The registered username |
password | TODO: check |
callBack | Result callback ValueCallBack#onSuccess(Object) indicates a successful callbackļ¼the parameter in onSuccess is the result of token ValueCallBack#onError(int, String) indicates a failure callback, the first parameter is the error code, the second parameter is the error description |
GroupManager io.agora.chat.ChatClient.groupManager | ( | ) |
Gets group manager, calls it after ChatClient has been initialized, see init(Context, ChatOptions)
void io.agora.chat.ChatClient.init | ( | Context | context, |
ChatOptions | options | ||
) |
Initialize the SDK Need initialize The SDK in main process
context | Not be null |
options | Configurations, not be null, see ChatOptions |
boolean io.agora.chat.ChatClient.isConnected | ( | ) |
Checks if connected to chat server.
boolean io.agora.chat.ChatClient.isFCMAvailable | ( | ) |
Check whether FCM push is available
boolean io.agora.chat.ChatClient.isLoggedInBefore | ( | ) |
Uses to check if user has been logged in before and did not logout If you need check if connected to server, please use isConnected()
if(ChatClient.getInstance().isLoggedInBefore()){ // enter main activity }else{ // enter login activity }
void io.agora.chat.ChatClient.kickAllDevices | ( | String | username, |
String | password | ||
) | throws ChatException |
void io.agora.chat.ChatClient.kickDevice | ( | String | username, |
String | password, | ||
String | resource | ||
) | throws ChatException |
Forced to logout the specified logged in device under the specified account, resource: DeviceInfo#getResource()
Synchronization method block the current thread
username | The account you want to kick a device off |
password | The account's password |
resource | The device ID, see DeviceInfo#getResource() |
void io.agora.chat.ChatClient.login | ( | String | id, |
String | password, | ||
final CallBack | callback | ||
) | throws IllegalArgumentException |
Login to chat server by login id and password Login to chat server by login id and token, see loginWithToken(String, String, CallBack)
Asynchronously method
id | Unique chat Login ID Not be null |
password | Password for this chat ID Not be null |
callback | Login callback Not be null, the result of login is returned via the callback |
IllegalArgumentException | If id, password, callback or appkey is null throws an exception. |
void io.agora.chat.ChatClient.loginWithToken | ( | String | username, |
String | token, | ||
final CallBack | callback | ||
) |
Login to chat server by login id and token Other method login to chat server by login id and token, see login(String, String, CallBack)
Asynchronously method
username | Unique chat Login ID Not be null |
token | Password for this chat ID Not be null |
callback | Login callback Not be null, the result of login is returned via the callback |
RuntimeException | If appkey is null throws a RuntimeException |
IllegalArgumentException | If Id, token or callback is null throws an exception |
int io.agora.chat.ChatClient.logout | ( | boolean | unbindToken | ) |
logout and return the result
Synchronization method block the current thread
unbindToken | whether unbind token true means to unbind the device token when logout false means to not unbind the device token when logout |
void io.agora.chat.ChatClient.logout | ( | final boolean | unbindToken, |
final CallBack | callback | ||
) |
Logout hyphenate chat server
Asynchronously method
unbindToken | whether unbind token true means to unbind the device token when logout false means to not unbind the device token when logout |
callback | EMCallback CallBack#onSuccess() indicates a successful logout callback CallBack#onError(int, String) indicates a failure logout callback, the first parameter means the error code, see Error, the second parameter means the error description |
PushManager io.agora.chat.ChatClient.pushManager | ( | ) |
Gets push manager, calls it after ChatClient has been initialized, see init(Context, ChatOptions)
void io.agora.chat.ChatClient.removeConnectionListener | ( | final ConnectionListener | listener | ) |
Remove chat server connection listener
listener | Chat server connection listener |
void io.agora.chat.ChatClient.removeMultiDeviceListener | ( | MultiDeviceListener | listener | ) |
remove multiple devices listener
listener | See MultiDeviceListener |
void io.agora.chat.ChatClient.sendFCMTokenToServer | ( | String | fcmToken | ) |
Upload the FCM token to chat server
The token can be uploaded when all the following conditions are met: 1.The token is not empty 2.User logged in 3.Device support google play service 4.Push type is FCM io.agora.push.PushType#FCM, You can set with ChatOptions#setFCMNumber(String)
fcmToken | The token want to upload |
void io.agora.chat.ChatClient.sendHMSPushTokenToServer | ( | String | appId, |
String | token | ||
) |
Send Huawei devices token to server
appId | Huawei appId |
token | Huawei device token Use sendHMSPushTokenToServer(String) for instead. |
void io.agora.chat.ChatClient.sendHMSPushTokenToServer | ( | String | token | ) |
Send Huawei devices token to server
token | Huawei device token |
void io.agora.chat.ChatClient.setDebugMode | ( | boolean | debugMode | ) |
Sets whether output debug info, should calls after ChatClient has been initialized, see init(Context, ChatOptions) SDK will out put debug info if debugMode = true
debugMode | Enter true, SDK will output debug info, enter false will not output |
boolean io.agora.chat.ChatClient.updateCurrentUserNick | ( | String | nickname | ) | throws IllegalArgumentException, ChatException |
Updates current user's push nickname, which is used to display in the notification bar when pushing Now use PushManager#updatePushNickname(String) instead Need to distinguish the nickname in user properties Recommended to update the push nickname to chat server after getting the user information from the user server; When the nickname of user information change, we need to update to chat server to prevent display discrepancies
nickname | Not be null, the length is not more than 100 characters |
void io.agora.chat.ChatClient.uploadLog | ( | CallBack | callback | ) |
upload local log file
Synchronization method block the current thread
callback | Not use in here |
UserInfoManager io.agora.chat.ChatClient.userInfoManager | ( | ) |
Gets user info manager, calls it after ChatClient has been initialized, see init(Context, ChatOptions)