hyphenate_SDK3.0  3.5.5
hyphenatejavaIMSDK
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 ()
 
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)
 
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 ()
 
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.5.5"
 

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

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

add connection listener

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

add multiple devices listener

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

get call manager

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

change appkey. Can ONLY be changed if not logged in

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

get chat manager

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

get chatroom manager

Returns
EMChatRoomManager
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.

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
EMConferenceManager com.hyphenate.chat.EMClient.conferenceManager ( )

get Conference manager

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

get contact manager

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

create an IM account on server

Parameters
username
password
String com.hyphenate.chat.EMClient.getAccessToken ( )

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

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

get current logged in user id

Returns
current logged in user
List<EMDeviceInfo> com.hyphenate.chat.EMClient.getLoggedInDevicesFromServer ( String  username,
String  password 
) throws HyphenateException

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

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

get EMOptions

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

get robot list

Exceptions
HyphenateException
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
EMGroupManager com.hyphenate.chat.EMClient.groupManager ( )

get group manager

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

initialize the SDK

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

check if connected to server.

Returns
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
void com.hyphenate.chat.EMClient.kickAllDevices ( String  username,
String  password 
) throws HyphenateException

multi-device: Forced to logout all logged in devices

Exceptions
HyphenateException
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
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
int com.hyphenate.chat.EMClient.logout ( boolean  unbindToken)

logout

Parameters
unbindTokenwhether unbind token
void com.hyphenate.chat.EMClient.logout ( final boolean  unbindToken,
final EMCallBack  callback 
)

logout hyphenate IM server synchronously

Parameters
unbindTokenwhether unbind token
callbackEMCallback
void com.hyphenate.chat.EMClient.removeConnectionListener ( final EMConnectionListener  listener)

remove connection listener

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

remove multiple devices listener

Parameters
listener
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
void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer ( String  appId,
String  token 
)

Send Huawei devices token to server

Parameters
appIdHuawei appId
tokenHuawei device token

Use sendHMSPushTokenToServer(String) for instead.

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

SDK will out put debug info if debugMode = true

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

upload local log file


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