hyphenate_SDK3.0 3.7.6.3
hyphenate java IM SDK
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
com.hyphenate.chat.EMClient Class Reference

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 addClientListener (final EMClientListener listener)
 
void removeClientListener (final EMClientListener listener)
 
void removeConnectionListener (final EMConnectionListener listener)
 
EMGroupManager groupManager ()
 
EMPushManager pushManager ()
 
EMChatRoomManager chatroomManager ()
 
EMChatManager chatManager ()
 
EMContactManager contactManager ()
 
EMCallManager callManager ()
 
EMConferenceManager conferenceManager ()
 
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)
 
List< EMContactgetRobotsFromServer () throws HyphenateException
 
EMOptions getOptions ()
 
String compressLogs () throws HyphenateException
 
void addMultiDeviceListener (EMMultiDeviceListener listener)
 
void removeMultiDeviceListener (EMMultiDeviceListener listener)
 
List< EMDeviceInfogetLoggedInDevicesFromServer (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.7.6.3"
 

Detailed Description

IM SDK Client, entrance of SDK, used to login, logout, and get access IM modules, such as

 EMChatManager chatManager = EMClient.getInstance().chatManager();

Member Function Documentation

◆ addConnectionListener()

void com.hyphenate.chat.EMClient.addConnectionListener ( final EMConnectionListener  listener)

add connection listener

Parameters
listener

◆ addMultiDeviceListener()

void com.hyphenate.chat.EMClient.addMultiDeviceListener ( EMMultiDeviceListener  listener)

add multiple devices listener

Parameters
listener

◆ callManager()

EMCallManager com.hyphenate.chat.EMClient.callManager ( )

get call manager

Returns
EMCallManager

◆ changeAppkey()

void com.hyphenate.chat.EMClient.changeAppkey ( String  appkey) throws HyphenateException

change appkey. Can ONLY be changed if not logged in

Parameters
appkey

◆ chatManager()

EMChatManager com.hyphenate.chat.EMClient.chatManager ( )

get chat manager

Returns
EMChatManager

◆ chatroomManager()

EMChatRoomManager com.hyphenate.chat.EMClient.chatroomManager ( )

get chatroom manager

Returns
EMChatRoomManager

◆ check()

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.

Parameters
usernameUser 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.
passwordThe password for username. if this is a logged in service check, the password would changed to the logged in password.
listenerA 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.

◆ compressLogs()

String com.hyphenate.chat.EMClient.compressLogs ( ) throws HyphenateException

compress log files, and return the compressed file

Exceptions
HyphenateException

compress log folder into zip file, return zip file path

Returns
compressed gz file
Exceptions
HyphenateExceptioncompress log files, and return the compressed file
HyphenateException

◆ conferenceManager()

EMConferenceManager com.hyphenate.chat.EMClient.conferenceManager ( )

get Conference manager

Returns
EMConferenceManager

◆ contactManager()

EMContactManager com.hyphenate.chat.EMClient.contactManager ( )

get contact manager

Returns
EMContactManager

◆ createAccount()

void com.hyphenate.chat.EMClient.createAccount ( String  username,
String  password 
) throws HyphenateException

create an IM account on server

Synchronization method block the current thread

Parameters
usernameThe 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.
passwordThe password you want to register, not be null. The password's length can not be longer than 64 bytes.
Exceptions
HyphenateExceptionIf user account or password is null, or account is illegal will throw exception. The exception while registering account will be thrown here.

◆ getAccessToken()

String com.hyphenate.chat.EMClient.getAccessToken ( )

获取身份认证权限 在上传下载附件(语音,图片,文件等)时必须添加到请求header中 当出现任何异常时将返回null, 可通过判断是否为null来检测是否有问题 如果为null,在打开EMLog日志时,是可以看到异常原因。

Returns

◆ getCurrentUser()

synchronized String com.hyphenate.chat.EMClient.getCurrentUser ( )

get current logged in user id

Returns
current logged in user

◆ getLoggedInDevicesFromServer()

List< EMDeviceInfo > com.hyphenate.chat.EMClient.getLoggedInDevicesFromServer ( String  username,
String  password 
) throws HyphenateException

multi-device: Get all the information about the logged in devices

◆ getOptions()

EMOptions com.hyphenate.chat.EMClient.getOptions ( )

get EMOptions

◆ getRobotsFromServer()

List< EMContact > com.hyphenate.chat.EMClient.getRobotsFromServer ( ) throws HyphenateException

get robot list

Exceptions
HyphenateException

◆ getUserTokenFromServer()

void com.hyphenate.chat.EMClient.getUserTokenFromServer ( final String  username,
final String  password,
final EMValueCallBack< String >  callBack 
)

Fetch token by username and password.

Parameters
callBackresult callback

◆ groupManager()

EMGroupManager com.hyphenate.chat.EMClient.groupManager ( )

get group manager

Returns
EMGroupManager

◆ init()

void com.hyphenate.chat.EMClient.init ( Context  context,
EMOptions  options 
)

initialize the SDK

◆ isConnected()

boolean com.hyphenate.chat.EMClient.isConnected ( )

check if connected to server.

Returns

◆ isLoggedInBefore()

boolean com.hyphenate.chat.EMClient.isLoggedInBefore ( )

used 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
}
Returns

◆ isSdkInited()

boolean com.hyphenate.chat.EMClient.isSdkInited ( )

Determine if the SDK has been initialized

Returns
Whether the SDK has been initialized

◆ kickAllDevices()

void com.hyphenate.chat.EMClient.kickAllDevices ( String  username,
String  password 
) throws HyphenateException

multi-device: Forced to logout all logged in devices

Exceptions
HyphenateException

◆ kickDevice()

void com.hyphenate.chat.EMClient.kickDevice ( String  username,
String  password,
String  resource 
) throws HyphenateException

multi-device: Forced to logout the specified logged in device, resource: EMDeviceInfo#getResource()

Parameters
username
password
resource
Exceptions
HyphenateException

◆ login()

void com.hyphenate.chat.EMClient.login ( String  id,
String  password,
final EMCallBack  callback 
) throws IllegalArgumentException

login to IM server

Parameters
idunique IM Login ID
passwordpassword for this IM ID
callbacklogin callback
Exceptions
IllegalArgumentException

◆ logout() [1/2]

int com.hyphenate.chat.EMClient.logout ( boolean  unbindToken)

logout

Parameters
unbindTokenwhether unbind token

◆ logout() [2/2]

void com.hyphenate.chat.EMClient.logout ( final boolean  unbindToken,
final EMCallBack  callback 
)

logout hyphenate IM server synchronously

Parameters
unbindTokenwhether unbind token
callbackEMCallback

◆ removeConnectionListener()

void com.hyphenate.chat.EMClient.removeConnectionListener ( final EMConnectionListener  listener)

remove connection listener

Parameters
listener

◆ removeMultiDeviceListener()

void com.hyphenate.chat.EMClient.removeMultiDeviceListener ( EMMultiDeviceListener  listener)

remove multiple devices listener

Parameters
listener

◆ sendFCMTokenToServer()

void com.hyphenate.chat.EMClient.sendFCMTokenToServer ( String  fcmToken)

Upload the FCM token to hyphenate server

The token will 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)

Parameters
fcmToken

◆ sendHMSPushTokenToServer()

void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer ( String  appId,
String  token 
)

Send Huawei devices token to server

Parameters
appIdHuawei appId
tokenHuawei device token

@Deprecated Use sendHMSPushTokenToServer(String) for instead.

◆ setDebugMode()

void com.hyphenate.chat.EMClient.setDebugMode ( boolean  debugMode)

SDK will out put debug info if debugMode = true

Parameters
debugMode

◆ uploadLog()

void com.hyphenate.chat.EMClient.uploadLog ( EMCallBack  callback)

upload local log file


The documentation for this class was generated from the following file: