hyphenate_SDK4.0 4.2.3-lite
hyphenate java IM SDK
|
Public Member Functions | |
void | init (Context context, EMOptions options) |
void | createAccount (String username, String password) throws HyphenateException |
void | login (String id, String password, @NonNull final EMCallBack callback) |
void | loginWithToken (String username, String token, @NonNull final EMCallBack callback) |
void | notifyTokenExpired (String response) |
void | renewToken (String newToken, @NonNull EMCallBack callback) |
int | logout (boolean unbindToken) |
void | logout (final boolean unbindToken, final EMCallBack callback) |
void | addConnectionListener (final EMConnectionListener listener) |
void | removeConnectionListener (final EMConnectionListener listener) |
void | addLogListener (final EMLogListener listener) |
void | removeLogListener (final EMLogListener listener) |
EMChatRoomManager | chatroomManager () |
EMChatManager | chatManager () |
Context | getContext () |
synchronized String | getCurrentUser () |
boolean | isLoggedInBefore () |
boolean | isConnected () |
boolean | isLoggedIn () |
void | setDebugMode (boolean debugMode) |
void | uploadLog (EMCallBack callback) |
EMOptions | getOptions () |
String | compressLogs () throws HyphenateException |
String | getAccessToken () |
boolean | isSdkInited () |
The chat client class, which is the entry of the chat SDK. It defines how to log in to and log out of the chat app and how to manage the connection between the SDK and the chat server.
void com.hyphenate.chat.EMClient.addConnectionListener | ( | final EMConnectionListener | listener | ) |
Adds a connection status listener.
The listener listens for the connection between the chat app and the chat server.
listener | The connection status listener to add.
|
void com.hyphenate.chat.EMClient.addLogListener | ( | final EMLogListener | listener | ) |
Adds the log callback listener of SDK.
listener | The log callback listener, EMLogListener#onLog(String). |
EMChatManager com.hyphenate.chat.EMClient.chatManager | ( | ) |
Gets the ChatManager
class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
ChatManager
class. EMChatRoomManager com.hyphenate.chat.EMClient.chatroomManager | ( | ) |
Gets the GroupManager
class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
GroupManager
class.Gets the PushManager
class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
PushManager
class.Gets the ChatRoomManager
class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
ChatRoomManager
class. String com.hyphenate.chat.EMClient.compressLogs | ( | ) | throws HyphenateException |
Compresses the debug log file into a gzip archive.
It is strongly recommended that you delete this debug archive as soon as this method is called.
HyphenateException | A description of the cause of the exception if the method fails. |
void com.hyphenate.chat.EMClient.createAccount | ( | String | username, |
String | password | ||
) | throws HyphenateException |
Adds a new user account.
This method is not recommended and you are advised to call the RESTful API.
This is a synchronous method and blocks the current thread.
username | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. The user ID can contain characters of the following types:
|
password | The password. The maximum length is 64 characters. Ensure that you set this parameter. |
HyphenateException | A description of the issue that caused this call to fail. For example, the user account or password is null, or the account is illegal. |
String com.hyphenate.chat.EMClient.getAccessToken | ( | ) |
Gets the access token from the memory.
When uploading or downloading an attachment (a voice, image, or file), you must add the token to the request header. The SDK returns null
when any exception occurs.
If the token is null
, you can check the EMLog file for the possible reason.
You can also get the token from the server by calling EMOptions#getAccessToken(boolean) and passing true
.
Context com.hyphenate.chat.EMClient.getContext | ( | ) |
Gets the EMUserInfoManager
class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
EMUserInfoManager
class.Gets the ContactManager
class.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
ContactManager
class. synchronized String com.hyphenate.chat.EMClient.getCurrentUser | ( | ) |
Gets the user ID of the current logged-in user.
EMOptions com.hyphenate.chat.EMClient.getOptions | ( | ) |
Gets configuration options of the SDK.
void com.hyphenate.chat.EMClient.init | ( | Context | context, |
EMOptions | options | ||
) |
Initializes the SDK.
Make sure to initialize the SDK in the main thread.
context | The context. Make sure to set the parameter. |
options | The configuration options. Make sure to set the parameter. See EMOptions. |
boolean com.hyphenate.chat.EMClient.isConnected | ( | ) |
Checks whether the SDK is connected to the chat server.
true
: Yes;false
: No. boolean com.hyphenate.chat.EMClient.isLoggedIn | ( | ) |
Checks whether the user has logged in to the Chat app.
true
: Yes;false
: No. boolean com.hyphenate.chat.EMClient.isLoggedInBefore | ( | ) |
Checks whether the user has logged in before.
This method always returns true
if you log in successfully and have not called the logout() method yet.
If you need to check whether the SDK is connected to the server, call isConnected().
true
: The user has logged in before;false
: The user has not logged in before or has called the logout() method. boolean com.hyphenate.chat.EMClient.isSdkInited | ( | ) |
Checks whether the SDK is initialized.
true
: Yes.false
: No. void com.hyphenate.chat.EMClient.login | ( | String | id, |
String | password, | ||
@NonNull final EMCallBack | callback | ||
) |
Logs in to the chat server with a password.
Also, you can call loginWithToken(String, String, EMCallBack) to log in to the chat server with the user ID and token.
This is an asynchronous method.
id | The unique chat user ID. Make sure to set the parameter. |
password | The password. Make sure to set the parameter. |
callback | The login callback. Make sure to set the parameter. The login result is returned via the callback. |
void com.hyphenate.chat.EMClient.loginWithToken | ( | String | username, |
String | token, | ||
@NonNull final EMCallBack | callback | ||
) |
Logs in to the chat server with the user ID and token.
This method supports automatic login.
You can also call login(String, String, EMCallBack) to log in to the chat server with the user ID and password.
This is an asynchronous method.
username | The user ID. Make sure to set the parameter. |
token | The user token. Make sure to set this parameter. |
callback | The login callback. Make sure to set the parameter. Also, this parameter cannot be null . The result of login is returned via the callback. |
int com.hyphenate.chat.EMClient.logout | ( | boolean | unbindToken | ) |
Logs out of the chat app.
This is a synchronous method and blocks the current thread.
unbindToken | Whether to unbind the token upon logout.
|
void com.hyphenate.chat.EMClient.logout | ( | final boolean | unbindToken, |
final EMCallBack | callback | ||
) |
Logs out of the chat server.
This is an asynchronous method.
unbindToken | Whether to unbind the token upon logout.
|
callback | The completion callback, which contains the error message if the method call fails. |
void com.hyphenate.chat.EMClient.notifyTokenExpired | ( | String | response | ) |
Notifies that the token expires.
The SDK triggers the token expiry notification callback via connectionListener.
response | The request result, which includes the description of the issue that cause the method fails. |
void com.hyphenate.chat.EMClient.removeConnectionListener | ( | final EMConnectionListener | listener | ) |
Removes the connection status listener.
listener | The connection status listener to remove. |
void com.hyphenate.chat.EMClient.removeLogListener | ( | final EMLogListener | listener | ) |
Removes the log callback listener.
listener | The log callback listener. |
void com.hyphenate.chat.EMClient.renewToken | ( | String | newToken, |
@NonNull EMCallBack | callback | ||
) |
Renews the Agora token.
If you log in with a token and are notified by a callback method EMConnectionListener that the token is to be expired, you can call this method to update the token to avoid unknown issues caused by an invalid token.
newToken | The new token. |
callback | renew token callback. Make sure to set the parameter. The result of renew token is returned via the callback. |
void com.hyphenate.chat.EMClient.setDebugMode | ( | boolean | debugMode | ) |
Sets whether to output the debug information.
This method can be called only after the EMClient is initialized. See init(Context, EMOptions).
debugMode | Whether to output the debug information:
|
void com.hyphenate.chat.EMClient.uploadLog | ( | EMCallBack | callback | ) |
Uploads local logs.
The debug logs provide reference for our engineers to fix errors and improve system performance.
This is a synchronous method and blocks the current thread.
callback | Reserved parameter. |