hyphenate_SDK4.0 4.8.2
hyphenate java IM SDK
|
Public Member Functions | |
void | addContact (String username, String reason) throws HyphenateException |
void | asyncAddContact (final String username, final String reason, final EMCallBack callback) |
void | deleteContact (String username) throws HyphenateException |
void | deleteContact (String username, boolean keepConversation) throws HyphenateException |
void | asyncDeleteContact (final String username, final EMCallBack callback) |
List< String > | getAllContactsFromServer () throws HyphenateException |
void | asyncGetAllContactsFromServer (final EMValueCallBack< List< String > > callback) |
void | setContactListener (EMContactListener contactListener) |
void | removeContactListener (EMContactListener contactListener) |
void | addUserToBlackList (String username, boolean both) throws HyphenateException |
void | asyncAddUserToBlackList (final String username, final boolean both, final EMCallBack callback) |
void | saveBlackList (List< String > blackList) throws HyphenateException |
void | asyncSaveBlackList (final List< String > blackList, final EMCallBack callback) |
void | removeUserFromBlackList (String username) throws HyphenateException |
void | asyncRemoveUserFromBlackList (final String username, final EMCallBack callback) |
List< String > | getBlackListUsernames () |
List< String > | getBlackListFromServer () throws HyphenateException |
void | asyncGetBlackListFromServer (final EMValueCallBack< List< String > > callback) |
void | acceptInvitation (String username) throws HyphenateException |
void | asyncAcceptInvitation (final String username, final EMCallBack callback) |
void | declineInvitation (String username) throws HyphenateException |
void | asyncDeclineInvitation (final String username, final EMCallBack callback) |
List< String > | getContactsFromLocal () throws HyphenateException |
List< String > | getSelfIdsOnOtherPlatform () throws HyphenateException |
void | asyncGetSelfIdsOnOtherPlatform (final EMValueCallBack< List< String > > callback) |
void | asyncSetContactRemark (@NonNull String username, @NonNull String remark, EMCallBack callback) |
EMContact | fetchContactFromLocal (String username) throws HyphenateException |
void | asyncFetchAllContactsFromLocal (EMValueCallBack< List< EMContact > > callback) |
void | asyncFetchAllContactsFromServer (EMValueCallBack< List< EMContact > > callback) |
void | asyncFetchAllContactsFromServer (int limit, String cursor, EMValueCallBack< EMCursorResult< EMContact > > callback) |
The EMContactManager
is used to record, query, and modify contacts.
void com.hyphenate.chat.EMContactManager.acceptInvitation | ( | String | username | ) | throws HyphenateException |
Accepts a friend invitation。
This is a synchronous method and blocks the current thread.
For the asynchronous method, see asyncAcceptInvitation(String, EMCallBack)
.
username | The user who initiates the friend request. |
void com.hyphenate.chat.EMContactManager.addContact | ( | String | username, |
String | reason | ||
) | throws HyphenateException |
Adds a new contact.
This is a synchronous method and blocks the current thread.
Reference: For the asynchronous method, see asyncAddContact(String, String, EMCallBack)
.
username | The user ID of the contact to add. |
reason | (optional) The invitation message. Set the parameter as null or "" if you want to ignore this parameter. |
HyphenateException | A description of the issue that caused this exception. |
void com.hyphenate.chat.EMContactManager.addUserToBlackList | ( | String | username, |
boolean | both | ||
) | throws HyphenateException |
Adds a user to the block list.
You can send messages to the users on the block list, but cannot receive message from them.
For the asynchronous method, see asyncAddUserToBlackList(String, boolean, EMCallBack)
.
You can add multiple users in bulk by calling saveBlackList(List)
.
This is a synchronous method and blocks the current thread.
username | The user to add to the block list. |
both | This parameter is deprecated. |
HyphenateException | A description of the issue that caused the exception. |
void com.hyphenate.chat.EMContactManager.asyncAcceptInvitation | ( | final String | username, |
final EMCallBack | callback | ||
) |
Accepts a friend invitation.
This an asynchronous method.
For the synchronous method, see acceptInvitation(String)
.
username | The user who initiates the friend request. |
callback | The SDK returns Success if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncAddContact | ( | final String | username, |
final String | reason, | ||
final EMCallBack | callback | ||
) |
Adds a new contact.
This is an asynchronous method.
Reference: For the synchronous method, see addContact(String, String)
username | The user ID of the contact to add. |
reason | (optional) The invitation message. Set the parameter as null or "" if you want to ignore this parameter. |
callback | The result of the method, which contains the error information if the method fails. |
void com.hyphenate.chat.EMContactManager.asyncAddUserToBlackList | ( | final String | username, |
final boolean | both, | ||
final EMCallBack | callback | ||
) |
Adds a user to the block list.
You can send messages to the users on the block list, but cannot receive message from them.
For the synchronous method, see addUserToBlackList(String, boolean)
.
You can add multiple users in bulk by calling asyncSaveBlackList(List, EMCallBack)
.
username | The user to add to the block list. |
both | This parameter is deprecated. |
callback | The callback completion.
|
void com.hyphenate.chat.EMContactManager.asyncDeclineInvitation | ( | final String | username, |
final EMCallBack | callback | ||
) |
Declines a friend invitation.
This an asynchronous method.
For the synchronous method, see declineInvitation(String)
.
username | The user who initiates the friend request. |
callback | The SDK returns Success if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncDeleteContact | ( | final String | username, |
final EMCallBack | callback | ||
) |
Deletes a contact.
This is an asynchronous method.
For the synchronous method, see deleteContact(String)
.
username | The user ID of the contact to delete. |
callback | The SDK returns Success if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncFetchAllContactsFromLocal | ( | EMValueCallBack< List< EMContact > > | callback | ) |
Gets all contacts from the local database.
callback | The SDK returns Success plus all contacts if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncFetchAllContactsFromServer | ( | EMValueCallBack< List< EMContact > > | callback | ) |
Gets all contacts from the server.
callback | The SDK returns Success plus all contacts if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncFetchAllContactsFromServer | ( | int | limit, |
String | cursor, | ||
EMValueCallBack< EMCursorResult< EMContact > > | callback | ||
) |
Gets all contacts from the server with pagination.
limit | The number of contacts that you expect to get on each page.The value ranges from [1-50]. |
cursor | The cursor position from which to start getting data. Pass null or "" at the first call of this method to get the contacts that are added most recently. |
callback | EMCursorResult , including the cursor for the next query and the contact list object. For the last page, the cursor is an empty string. |
void com.hyphenate.chat.EMContactManager.asyncGetAllContactsFromServer | ( | final EMValueCallBack< List< String > > | callback | ) |
Get all contacts from the server.
This is a synchronous method see getAllContactsFromServer()
.
callback | The SDK returns the contact list if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncGetBlackListFromServer | ( | final EMValueCallBack< List< String > > | callback | ) |
Gets the block list from the server.
For the synchronous method, see getBlackListFromServer()
.
callback | The SDK returns the block list if the call succeed, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.asyncGetSelfIdsOnOtherPlatform | ( | final EMValueCallBack< List< String > > | callback | ) |
Gets the unique IDs of the current user on the other devices. The ID is in the format of user ID + "/" + resource (device ID).
This is an asynchronous method.
For the synchronous method, see getSelfIdsOnOtherPlatform()
.
callback | - The SDK returns the unique IDs of the current user on the other devices if the method succeeds.
|
void com.hyphenate.chat.EMContactManager.asyncRemoveUserFromBlackList | ( | final String | username, |
final EMCallBack | callback | ||
) |
Removes a contact from the block list.
For the synchronous method, see removeUserFromBlackList(String)
.
username | The user to be removed from the block list. |
callback | The completion callback.
|
void com.hyphenate.chat.EMContactManager.asyncSaveBlackList | ( | final List< String > | blackList, |
final EMCallBack | callback | ||
) |
Uploads the block list to the server.
For the synchronous method, see saveBlackList(List)
.
blackList | The block list to upload to the server. |
callback | The completion callback.
|
void com.hyphenate.chat.EMContactManager.asyncSetContactRemark | ( | @NonNull String | username, |
@NonNull String | remark, | ||
EMCallBack | callback | ||
) |
Sets remarks of a contact.
username | The user ID of the contact. |
remark | The remarks of the contact. |
callback | The completion callback. The SDK returns Success if the call succeeds, but the description of the cause if the call fails. |
void com.hyphenate.chat.EMContactManager.declineInvitation | ( | String | username | ) | throws HyphenateException |
Declines a friend invitation.
This is a synchronous method and blocks the current thread.
For the asynchronous method, see asyncDeclineInvitation(String, EMCallBack)
.
username | The user who initiates the invitation. |
void com.hyphenate.chat.EMContactManager.deleteContact | ( | String | username | ) | throws HyphenateException |
Deletes a contact and all the related conversations.
This is a synchronous method and blocks the current thread.
username | The user ID of the contact delete. |
HyphenateException | A description of the issue that caused the exception. |
void com.hyphenate.chat.EMContactManager.deleteContact | ( | String | username, |
boolean | keepConversation | ||
) | throws HyphenateException |
Deletes a contact.
This is a synchronous method and blocks the current thread.
username | The user ID. |
keepConversation | Whether to keep the related conversation and messages.
|
HyphenateException | A description of the issue that caused the exception. |
EMContact com.hyphenate.chat.EMContactManager.fetchContactFromLocal | ( | String | username | ) | throws HyphenateException |
Gets a contact from the local database.
username | The user ID of the contact. |
HyphenateException | A description of the issue that caused this call to fail. |
List< String > com.hyphenate.chat.EMContactManager.getAllContactsFromServer | ( | ) | throws HyphenateException |
Get all contacts from the server.
This is a synchronous method and blocks the current thread.
For the asynchronous method, see asyncGetAllContactsFromServer(EMValueCallBack)
.
HyphenateException | A description of the exception. |
List< String > com.hyphenate.chat.EMContactManager.getBlackListFromServer | ( | ) | throws HyphenateException |
Gets the block list from the server.
For the asynchronous method, see asyncGetBlackListFromServer(EMValueCallBack)
.
This is a synchronous method and blocks the current thread.
HyphenateException | A description of the issue that caused the exception. |
List< String > com.hyphenate.chat.EMContactManager.getBlackListUsernames | ( | ) |
Gets the local block list.
List< String > com.hyphenate.chat.EMContactManager.getContactsFromLocal | ( | ) | throws HyphenateException |
Gets the contact list from the local database.
HyphenateException | A description of the issue that caused the exception. |
List< String > com.hyphenate.chat.EMContactManager.getSelfIdsOnOtherPlatform | ( | ) | throws HyphenateException |
Gets the unique IDs of the current user on the other devices. The ID is in the format of user ID + "/" + resource (device ID).
This is a synchronous method and blocks the current thread.
For the asynchronous method, see asyncGetSelfIdsOnOtherPlatform(EMValueCallBack)
.
HyphenateException | A description of the issue that caused this call to fail. |
void com.hyphenate.chat.EMContactManager.removeContactListener | ( | EMContactListener | contactListener | ) |
Removes a contact listener.
You can add a contact listener by calling setContactListener(EMContactListener)
.
void com.hyphenate.chat.EMContactManager.removeUserFromBlackList | ( | String | username | ) | throws HyphenateException |
Removes the contact from the block list.
For the asynchronous method, see asyncRemoveUserFromBlackList(String, EMCallBack)
.
This is a synchronous method and blocks the current thread.
username | The user to be removed from the block list. |
HyphenateException | A description of the exception. |
void com.hyphenate.chat.EMContactManager.saveBlackList | ( | List< String > | blackList | ) | throws HyphenateException |
Uploads the block list to the server.
This is a synchronous method and blocks the current thread.
For the asynchronous method, see asyncSaveBlackList(List, EMCallBack)
.
blackList | The block list to upload to the server. |
void com.hyphenate.chat.EMContactManager.setContactListener | ( | EMContactListener | contactListener | ) |
Registers a new contact listener.
You can call removeContactListener(EMContactListener)
to remove the listener.
contactListener | The contact listener to register. |