hyphenate_SDK3.0
3.8.5
hyphenatejavaIMSDK
|
Classes | |
interface | AppStateListener |
interface | CheckResultListener |
class | MyConnectionListener |
class | MyMultiDeviceListener |
Public Member Functions | |
void | init (Context context, EMOptions options) |
void | createAccount (String username, String password) throws HyphenateException |
void | login (String id, String password, final EMCallBack callback) throws IllegalArgumentException |
void | loginWithToken (String username, String token, final EMCallBack callback) |
int | logout (boolean unbindToken) |
void | logout (final boolean unbindToken, final EMCallBack callback) |
void | changeAppkey (String appkey) throws HyphenateException |
void | addConnectionListener (final EMConnectionListener listener) |
void | removeConnectionListener (final EMConnectionListener listener) |
EMGroupManager | groupManager () |
EMPushManager | pushManager () |
EMChatRoomManager | chatroomManager () |
EMChatManager | chatManager () |
EMUserInfoManager | userInfoManager () |
EMContactManager | contactManager () |
Context | getContext () |
synchronized String | getCurrentUser () |
void | getUserTokenFromServer (final String username, final String password, final EMValueCallBack< String > callBack) |
boolean | isLoggedInBefore () |
boolean | isConnected () |
void | setDebugMode (boolean debugMode) |
boolean | updateCurrentUserNick (String nickname) throws IllegalArgumentException, HyphenateException |
void | uploadLog (EMCallBack callback) |
EMOptions | getOptions () |
String | compressLogs () throws HyphenateException |
void | addMultiDeviceListener (EMMultiDeviceListener listener) |
void | removeMultiDeviceListener (EMMultiDeviceListener listener) |
List< EMDeviceInfo > | getLoggedInDevicesFromServer (String username, String password) throws HyphenateException |
void | kickDevice (String username, String password, String resource) throws HyphenateException |
void | kickAllDevices (String username, String password) throws HyphenateException |
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 EMClient | getInstance () |
Static Public Attributes | |
static final String | TAG = "EMClient" |
static final String | VERSION = "3.8.5" |
Chat SDK Client, entrance of SDK, used to login, logout, and get access chat modules, such as
EMChatManager chatManager = EMClient.getInstance().chatManager();
void com.hyphenate.chat.EMClient.addConnectionListener | ( | final EMConnectionListener | listener | ) |
Add chat server connection listener
listener | Chat server connection listener EMConnectionListener#onConnected() indicates a successful connection to chat server EMConnectionListener#onDisconnected(int) indicates a failure connection to chat server, the parameter means the error code, see EMError |
void com.hyphenate.chat.EMClient.addMultiDeviceListener | ( | EMMultiDeviceListener | listener | ) |
add multiple devices listener
listener | See EMMultiDeviceListener, EMMultiDeviceListener#onContactEvent(int, String, String) is the contact event callback, EMMultiDeviceListener#onGroupEvent(int, String, List) is the group event callback |
void com.hyphenate.chat.EMClient.changeAppkey | ( | String | appkey | ) | throws HyphenateException |
Change appkey Can ONLY be changed if not logged in Also can set appkey by EMOptions#setAppKey(String), need be set if not logged in
appkey | Not be null or "" |
EMChatManager com.hyphenate.chat.EMClient.chatManager | ( | ) |
Gets chat manager, calls it after EMClient has been initialized, see init(Context, EMOptions)
EMChatRoomManager com.hyphenate.chat.EMClient.chatroomManager | ( | ) |
Gets chat room manager, calls it after EMClient has been initialized, see init(Context, EMOptions)
void com.hyphenate.chat.EMClient.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 com.hyphenate.chat.EMClient.compressLogs | ( | ) | throws HyphenateException |
Compress log folder into zip file, return zip file path
HyphenateException | The exception by Compress gz file |
EMContactManager com.hyphenate.chat.EMClient.contactManager | ( | ) |
Gets contact manager, calls it after EMClient has been initialized, see init(Context, EMOptions)
void com.hyphenate.chat.EMClient.createAccount | ( | String | username, |
String | password | ||
) | throws HyphenateException |
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. |
HyphenateException | If user account or password is null, or account is illegal will throw exception. The exception while registering account will be thrown here. |
String com.hyphenate.chat.EMClient.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 EMOptions#getAccessToken(). If you want to get token from server, can call EMOptions#getAccessToken(boolean) and enter true
synchronized String com.hyphenate.chat.EMClient.getCurrentUser | ( | ) |
Gets current login user ID
List<EMDeviceInfo> com.hyphenate.chat.EMClient.getLoggedInDevicesFromServer | ( | String | username, |
String | password | ||
) | throws HyphenateException |
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 |
HyphenateException | See EMError |
void com.hyphenate.chat.EMClient.getUserTokenFromServer | ( | final String | username, |
final String | password, | ||
final EMValueCallBack< String > | callBack | ||
) |
Fetch token by username and password
username | The registered username |
password | TODO: check |
callBack | Result callback EMValueCallBack#onSuccess(Object) indicates a successful callbackļ¼the parameter in onSuccess is the result of token EMValueCallBack#onError(int, String) indicates a failure callback, the first parameter is the error code, the second parameter is the error description |
EMGroupManager com.hyphenate.chat.EMClient.groupManager | ( | ) |
Gets group manager, calls it after EMClient has been initialized, see init(Context, EMOptions)
void com.hyphenate.chat.EMClient.init | ( | Context | context, |
EMOptions | options | ||
) |
Initialize the SDK Need initialize The SDK in main process
context | Not be null |
options | Configurations, not be null, see EMOptions |
boolean com.hyphenate.chat.EMClient.isConnected | ( | ) |
Checks if connected to chat server.
boolean com.hyphenate.chat.EMClient.isFCMAvailable | ( | ) |
Check whether FCM push is available
boolean com.hyphenate.chat.EMClient.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(EMClient.getInstance().isLoggedInBefore()){ // enter main activity }else{ // enter login activity }
boolean com.hyphenate.chat.EMClient.isSdkInited | ( | ) |
Determine if the SDK has been initialized
void com.hyphenate.chat.EMClient.kickAllDevices | ( | String | username, |
String | password | ||
) | throws HyphenateException |
Forced to logout all logged in devices under the specified account
Synchronization method block the current thread
username | The account you want to kick all the devices |
password | The account's password |
HyphenateException | Error code see EMError |
void com.hyphenate.chat.EMClient.kickDevice | ( | String | username, |
String | password, | ||
String | resource | ||
) | throws HyphenateException |
Forced to logout the specified logged in device under the specified account, resource: EMDeviceInfo#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 EMDeviceInfo#getResource() |
HyphenateException | Error code see EMError |
void com.hyphenate.chat.EMClient.login | ( | String | id, |
String | password, | ||
final EMCallBack | 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, EMCallBack)
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 com.hyphenate.chat.EMClient.loginWithToken | ( | String | username, |
String | token, | ||
final EMCallBack | 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, EMCallBack)
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 com.hyphenate.chat.EMClient.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 com.hyphenate.chat.EMClient.logout | ( | final boolean | unbindToken, |
final EMCallBack | 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 EMCallBack#onSuccess() indicates a successful logout callback EMCallBack#onError(int, String) indicates a failure logout callback, the first parameter means the error code, see EMError, the second parameter means the error description |
EMPushManager com.hyphenate.chat.EMClient.pushManager | ( | ) |
Gets push manager, calls it after EMClient has been initialized, see init(Context, EMOptions)
void com.hyphenate.chat.EMClient.removeConnectionListener | ( | final EMConnectionListener | listener | ) |
Remove chat server connection listener
listener | Chat server connection listener |
void com.hyphenate.chat.EMClient.removeMultiDeviceListener | ( | EMMultiDeviceListener | listener | ) |
remove multiple devices listener
listener | See EMMultiDeviceListener |
void com.hyphenate.chat.EMClient.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 com.hyphenate.push.EMPushType#FCM, You can set with EMOptions#setFCMNumber(String)
fcmToken | The token want to upload |
void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer | ( | String | appId, |
String | token | ||
) |
Send Huawei devices token to server
appId | Huawei appId |
token | Huawei device token Use sendHMSPushTokenToServer(String) for instead. |
void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer | ( | String | token | ) |
Send Huawei devices token to server
token | Huawei device token |
void com.hyphenate.chat.EMClient.setDebugMode | ( | boolean | debugMode | ) |
Sets whether output debug info, should calls after EMClient has been initialized, see init(Context, EMOptions) SDK will out put debug info if debugMode = true
debugMode | Enter true, SDK will output debug info, enter false will not output |
boolean com.hyphenate.chat.EMClient.updateCurrentUserNick | ( | String | nickname | ) | throws IllegalArgumentException, HyphenateException |
Updates current user's push nickname, which is used to display in the notification bar when pushing Now use EMPushManager#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 com.hyphenate.chat.EMClient.uploadLog | ( | EMCallBack | callback | ) |
upload local log file
Synchronization method block the current thread
callback | Not use in here |
EMUserInfoManager com.hyphenate.chat.EMClient.userInfoManager | ( | ) |
Gets user info manager, calls it after EMClient has been initialized, see init(Context, EMOptions)