hyphenate_SDK3.0
3.8.1
hyphenatejavaIMSDK
|
类 | |
interface | AppStateListener |
interface | CheckResultListener |
class | MyConnectionListener |
class | MyMultiDeviceListener |
Public 成员函数 | |
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 () |
EMUserInfoManager | userInfoManager () |
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< 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) |
静态 Public 成员函数 | |
static EMClient | getInstance () |
静态 Public 属性 | |
static final String | TAG = "EMClient" |
static final String | VERSION = "3.8.1" |
IM SDK的入口,负责登录退出及连接管理等,由此可以获得其他模块的入口
EMChatManager chatManager = EMClient.getInstance().chatManager();
void com.hyphenate.chat.EMClient.addConnectionListener | ( | final EMConnectionListener | listener | ) |
添加EMConnectionListener
listener |
void com.hyphenate.chat.EMClient.addMultiDeviceListener | ( | EMMultiDeviceListener | listener | ) |
添加多设备监听的接口
listener |
EMCallManager com.hyphenate.chat.EMClient.callManager | ( | ) |
获取EMCallManager
void com.hyphenate.chat.EMClient.changeAppkey | ( | String | appkey | ) | throws HyphenateException |
更改appkey,注意只有在未登录状态才能修改appkey
appkey |
EMChatManager com.hyphenate.chat.EMClient.chatManager | ( | ) |
获取EMChatManager
EMChatRoomManager com.hyphenate.chat.EMClient.chatroomManager | ( | ) |
获取EMChatRoomManager
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.
String com.hyphenate.chat.EMClient.compressLogs | ( | ) | throws HyphenateException |
压缩log文件,并返回压缩后的文件路径
HyphenateException |
EMConferenceManager com.hyphenate.chat.EMClient.conferenceManager | ( | ) |
获取EMConferenceManager
EMContactManager com.hyphenate.chat.EMClient.contactManager | ( | ) |
获取EMContactManager
void com.hyphenate.chat.EMClient.createAccount | ( | String | username, |
String | password | ||
) | throws HyphenateException |
创建账号
username | |
password |
String com.hyphenate.chat.EMClient.getAccessToken | ( | ) |
获取身份认证权限 在上传下载附件(语音,图片,文件等)时必须添加到请求header中 当出现任何异常时将返回null, 可通过判断是否为null来检测是否有问题 如果为null,在打开EMLog日志时,是可以看到异常原因。
synchronized String com.hyphenate.chat.EMClient.getCurrentUser | ( | ) |
获取当前登录用户的用户名
List<EMDeviceInfo> com.hyphenate.chat.EMClient.getLoggedInDevicesFromServer | ( | String | username, |
String | password | ||
) | throws HyphenateException |
获取账号名下登陆的在线设备列表
HyphenateException |
EMOptions com.hyphenate.chat.EMClient.getOptions | ( | ) |
获取EMOptions
List<EMContact> com.hyphenate.chat.EMClient.getRobotsFromServer | ( | ) | throws HyphenateException |
void com.hyphenate.chat.EMClient.getUserTokenFromServer | ( | final String | username, |
final String | password, | ||
final EMValueCallBack< String > | callBack | ||
) |
根据用户名和密码获取token
username | 用户名 |
password | 密码 |
callBack | 结果回调 |
EMGroupManager com.hyphenate.chat.EMClient.groupManager | ( | ) |
获取EMGroupManager
void com.hyphenate.chat.EMClient.init | ( | Context | context, |
EMOptions | options | ||
) |
初始化SDK。
boolean com.hyphenate.chat.EMClient.isConnected | ( | ) |
检查是否连接到聊天服务器
boolean com.hyphenate.chat.EMClient.isLoggedInBefore | ( | ) |
返回是否登录过 登录成功过没调logout方法,这个方法的返回值一直是true 如果需要判断当前是否连接到服务器,请使用isConnected()方法
if(EMClient.getInstance().isLoggedInBefore()){ // enter main activity }else{ // enter login activity }
void com.hyphenate.chat.EMClient.kickAllDevices | ( | String | username, |
String | password | ||
) | throws HyphenateException |
将该账号下的所有设备都踢下线
HyphenateException |
void com.hyphenate.chat.EMClient.kickDevice | ( | String | username, |
String | password, | ||
String | resource | ||
) | throws HyphenateException |
根据设备ID,将该设备下线, 设备ID:EMDeviceInfo#getResource()
username | 账户名称 |
password | 该账户密码 |
resource | 设备ID |
HyphenateException |
void com.hyphenate.chat.EMClient.login | ( | String | id, |
String | password, | ||
final EMCallBack | callback | ||
) | throws IllegalArgumentException |
登录IM服务器
id | 用户id |
password | 用户密码 |
callback | EMCallback回调函数 |
IllegalArgumentException |
int com.hyphenate.chat.EMClient.logout | ( | boolean | unbindToken | ) |
退出
unbindToken | 是否解绑token |
void com.hyphenate.chat.EMClient.logout | ( | final boolean | unbindToken, |
final EMCallBack | callback | ||
) |
异步登出聊天服务器
unbindToken | 是否解绑token |
callback | EMCallback回调 |
void com.hyphenate.chat.EMClient.removeConnectionListener | ( | final EMConnectionListener | listener | ) |
删除EMConnectionListener
listener |
void com.hyphenate.chat.EMClient.removeMultiDeviceListener | ( | EMMultiDeviceListener | listener | ) |
删除多设备监听的接口
listener |
void com.hyphenate.chat.EMClient.sendFCMTokenToServer | ( | String | fcmToken | ) |
上传FCM token至服务器
token可以被上传的前提条件有: 1.被上传的token不为空 2.当前已有用户登录 3.当前设备支持google推送 4.google推送类型为FCM com.hyphenate.push.EMPushType#FCM 设置推送类型为FCM的接口为EMOptions#setFCMNumber(String),即设置了FCM number则推送类型为FCM
void com.hyphenate.chat.EMClient.sendHMSPushTokenToServer | ( | String | appId, |
String | token | ||
) |
发送华为推送 token 到服务器
appId | 华为 appId |
token | 华为推送 token |
void com.hyphenate.chat.EMClient.setDebugMode | ( | boolean | debugMode | ) |
debugMode == true 时,sdk 会在log里输出调试信息
debugMode |
boolean com.hyphenate.chat.EMClient.updateCurrentUserNick | ( | String | nickname | ) | throws IllegalArgumentException, HyphenateException |
更新当前用户的nickname 此方法主要为了在苹果推送时能够推送nick而不是userid 一般可以在登陆成功后从自己服务器获取到个人信息,然后拿到nick更新到环信服务器 并且,在个人信息中如果更改个人的昵称,也要把环信服务器更新下nickname 防止显示差异
nickname | 昵称 |
void com.hyphenate.chat.EMClient.uploadLog | ( | EMCallBack | callback | ) |
上传本地的log
EMUserInfoManager com.hyphenate.chat.EMClient.userInfoManager | ( | ) |
获取EMUserInfoManager