|
interface | AppStateListener |
|
interface | CheckResultListener |
|
class | MyConnectionListener |
|
class | MyMultiDeviceListener |
|
|
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< EMContact > | getRobotsFromServer () throws HyphenateException |
|
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 () |
|
EMChatConfigPrivate | getChatConfigPrivate () |
|
JSONObject | getDeviceInfo () |
|
void | check (String username, String password, final CheckResultListener listener) |
|
|
static final String | TAG = "EMClient" |
|
static final String | VERSION = "3.6.1" |
|
IM SDK的入口,负责登录退出及连接管理等,由此可以获得其他模块的入口
EMChatManager chatManager = EMClient.getInstance().chatManager();
◆ addConnectionListener()
添加EMConnectionListener
- 参数
-
◆ addMultiDeviceListener()
◆ callManager()
◆ changeAppkey()
void com.hyphenate.chat.EMClient.changeAppkey |
( |
String |
appkey | ) |
throws HyphenateException |
更改appkey,注意只有在未登录状态才能修改appkey
- 参数
-
◆ chatManager()
◆ chatroomManager()
◆ check()
void com.hyphenate.chat.EMClient.check |
( |
String |
username, |
|
|
String |
password, |
|
|
final CheckResultListener |
listener |
|
) |
| |
服务诊断接口,流程如下: 1.校验用户名和密码 2.从服务端获取DNS列表 3.从服务端获取Token 4.连接IM服务器 5.断开连接(如果检查前已经有账户登录,则不执行该步骤)
如果在诊断过程中产生了错误,该流程将会被打断.
- 参数
-
username | 用于服务诊断的用户名,如果已有账户登录,该用户名会被替换为已登录账户的用户名,以防止更改当前已登录账户 的信息,比如Token等... |
password | 密码,如果已有账户登录,该密码会被替换为已登录账户的密码. |
listener | 诊断结果回调 |
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 |
压缩log文件,并返回压缩后的文件路径
- 返回
- compressed gz file
- 异常
-
◆ conferenceManager()
◆ contactManager()
◆ createAccount()
void com.hyphenate.chat.EMClient.createAccount |
( |
String |
username, |
|
|
String |
password |
|
) |
| throws HyphenateException |
◆ getAccessToken()
String com.hyphenate.chat.EMClient.getAccessToken |
( |
| ) |
|
获取身份认证权限 在上传下载附件(语音,图片,文件等)时必须添加到请求header中 当出现任何异常时将返回null, 可通过判断是否为null来检测是否有问题 如果为null,在打开EMLog日志时,是可以看到异常原因。
- 返回
◆ getCurrentUser()
String com.hyphenate.chat.EMClient.getCurrentUser |
( |
| ) |
|
◆ getLoggedInDevicesFromServer()
List<EMDeviceInfo> com.hyphenate.chat.EMClient.getLoggedInDevicesFromServer |
( |
String |
username, |
|
|
String |
password |
|
) |
| throws HyphenateException |
获取账号名下登陆的在线设备列表
- 返回
- 在线设备列表
- 异常
-
◆ getOptions()
EMOptions com.hyphenate.chat.EMClient.getOptions |
( |
| ) |
|
◆ getRobotsFromServer()
List<EMContact> com.hyphenate.chat.EMClient.getRobotsFromServer |
( |
| ) |
throws HyphenateException |
◆ getUserTokenFromServer()
void com.hyphenate.chat.EMClient.getUserTokenFromServer |
( |
final String |
username, |
|
|
final String |
password, |
|
|
final EMValueCallBack< String > |
callBack |
|
) |
| |
根据用户名和密码获取token
- 参数
-
username | 用户名 |
password | 密码 |
callBack | 结果回调 |
◆ groupManager()
◆ init()
void com.hyphenate.chat.EMClient.init |
( |
Context |
context, |
|
|
EMOptions |
options |
|
) |
| |
◆ isConnected()
boolean com.hyphenate.chat.EMClient.isConnected |
( |
| ) |
|
◆ isLoggedInBefore()
boolean com.hyphenate.chat.EMClient.isLoggedInBefore |
( |
| ) |
|
返回是否登录过 登录成功过没调logout方法,这个方法的返回值一直是true 如果需要判断当前是否连接到服务器,请使用isConnected()方法
if(EMClient.getInstance().isLoggedInBefore()){
// enter main activity
}else{
// enter login activity
}
- 返回
◆ kickAllDevices()
void com.hyphenate.chat.EMClient.kickAllDevices |
( |
String |
username, |
|
|
String |
password |
|
) |
| throws HyphenateException |
◆ kickDevice()
void com.hyphenate.chat.EMClient.kickDevice |
( |
String |
username, |
|
|
String |
password, |
|
|
String |
resource |
|
) |
| throws HyphenateException |
◆ login()
void com.hyphenate.chat.EMClient.login |
( |
String |
id, |
|
|
String |
password, |
|
|
final EMCallBack |
callback |
|
) |
| throws IllegalArgumentException |
登录IM服务器
- 参数
-
id | 用户id |
password | 用户密码 |
callback | EMCallback回调函数 |
- 异常
-
◆ logout() [1/2]
int com.hyphenate.chat.EMClient.logout |
( |
boolean |
unbindToken | ) |
|
◆ logout() [2/2]
void com.hyphenate.chat.EMClient.logout |
( |
final boolean |
unbindToken, |
|
|
final EMCallBack |
callback |
|
) |
| |
异步登出聊天服务器
- 参数
-
unbindToken | 是否解绑token |
callback | EMCallback回调 |
◆ removeConnectionListener()
删除EMConnectionListener
- 参数
-
◆ removeMultiDeviceListener()
◆ sendFCMTokenToServer()
void com.hyphenate.chat.EMClient.sendFCMTokenToServer |
( |
String |
fcmToken | ) |
|
◆ sendHMSPushTokenToServer()
void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer |
( |
String |
appId, |
|
|
String |
token |
|
) |
| |
发送华为推送 token 到服务器
- 参数
-
appId | 华为 appId |
token | 华为推送 token |
◆ setDebugMode()
void com.hyphenate.chat.EMClient.setDebugMode |
( |
boolean |
debugMode | ) |
|
debugMode == true 时,sdk 会在log里输出调试信息
- 参数
-
◆ updateCurrentUserNick()
boolean com.hyphenate.chat.EMClient.updateCurrentUserNick |
( |
String |
nickname | ) |
|
◆ uploadLog()
void com.hyphenate.chat.EMClient.uploadLog |
( |
EMCallBack |
callback | ) |
|
该类的文档由以下文件生成:
- hyphenatechatsdk/src/com/hyphenate/chat/EMClient.java