hyphenate_SDK3.0 4.0.0
hyphenate java IM SDK
Classes | Public Member Functions | List of all members
com.hyphenate.chat.EMContactManager Class Reference

Classes

class  EMAContactListenerImpl
 

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)
 

Detailed Description

The EMContactManager is used to record, query, and modify contacts.

Member Function Documentation

◆ acceptInvitation()

void com.hyphenate.chat.EMContactManager.acceptInvitation ( String  username) throws HyphenateException

Accepts a friend invitation。

This is a synchronous method and blocks the current thread.

Reference: For the asynchronous method, see asyncAcceptInvitation(String, EMCallBack)

Parameters
usernameThe user who initiates the friend request.

◆ addContact()

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).

Parameters
usernameThe user to be added.
reason(optional) The invitation message. Set the parameter as null if you want to ignore the information.
Exceptions
HyphenateExceptionA description of the issue that caused this exception.

◆ addUserToBlackList()

void com.hyphenate.chat.EMContactManager.addUserToBlackList ( String  username,
boolean  both 
) throws HyphenateException

Adds a user to blocklist. You can send message to the user in blocklist, but you can not receive the message sent by the other.

Reference: For the asynchronous method, see asyncAddUserToBlackList(String, boolean, EMCallBack). Adds the batch blocklist by calling saveBlackList(List).

This is a synchronous method and blocks the current thread.

Parameters
usernameThe user to be blocked.
bothThis parameter is deprecated.
Exceptions
HyphenateExceptionA description of the issue that caused the exception.

◆ asyncAcceptInvitation()

void com.hyphenate.chat.EMContactManager.asyncAcceptInvitation ( final String  username,
final EMCallBack  callback 
)

Accepts a friend invitation.

This an asynchronous method.

Reference: For the synchronous method, see acceptInvitation(String).

Parameters
usernameThe user who initiates the friend request.
callbackReturns Success if the call succeed and the description of the cause if the call fails.

◆ asyncAddContact()

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)

Parameters
usernameThe user ID of the contact to be added.
reasonThe message for adding contact (optional).
callbackThe result of the method, which contains the error information if the method fails.

◆ asyncAddUserToBlackList()

void com.hyphenate.chat.EMContactManager.asyncAddUserToBlackList ( final String  username,
final boolean  both,
final EMCallBack  callback 
)

Adds the user to blocklist. You can send message to the user in the blocklist, but you can not receive the message sent by the user in the blocklist.

Reference: For the synchronous method, see addUserToBlackList(String, boolean). If you want to add multiple users in a batch to the blocklist, see asyncSaveBlackList(List, EMCallBack).

Parameters
usernameThe user to be blocked.
bothThis parameter is deprecated.
callbackThe callback completion.
  • Success: The user is successfully added to the blocklist.
  • Error: The user fails to be added to the blocklist. In this case, an error message is returned.

◆ asyncDeclineInvitation()

void com.hyphenate.chat.EMContactManager.asyncDeclineInvitation ( final String  username,
final EMCallBack  callback 
)

Declines a friend invitation.

This an asynchronous method.

Reference: For the synchronous method, see declineInvitation(String).

Parameters
usernameThe user who initiates the friend request.
callbackReturns Success if the call succeed and the description of the cause if the call fails.

◆ asyncDeleteContact()

void com.hyphenate.chat.EMContactManager.asyncDeleteContact ( final String  username,
final EMCallBack  callback 
)

Deletes a contact.

This is an asynchronous method.

Reference: For the synchronous method, see deleteContact(String).

Parameters
usernameThe contact‘s user ID to be deleted.
callbackThe result of the method, which contains the error information if the method fails.

◆ asyncGetAllContactsFromServer()

void com.hyphenate.chat.EMContactManager.asyncGetAllContactsFromServer ( final EMValueCallBack< List< String > >  callback)

Get all contacts from the server.

Reference: This is a synchronous method see getAllContactsFromServer().

Parameters
callbackIf the method call succeeds, returns the list of contacts; if the method call fails, returns the error information.

◆ asyncGetBlackListFromServer()

void com.hyphenate.chat.EMContactManager.asyncGetBlackListFromServer ( final EMValueCallBack< List< String > >  callback)

Gets the blocklist from the server.

Reference: For the synchronous method, see getBlackListFromServer().

Parameters
callbackReturns the blocklist if the call succeed and the description of the cause if the call fails.

◆ asyncGetSelfIdsOnOtherPlatform()

void com.hyphenate.chat.EMContactManager.asyncGetSelfIdsOnOtherPlatform ( final EMValueCallBack< List< String > >  callback)

Get the unique selfID list of the current user on the other devices. The selfID contains username + "/" + resource(the device ID).

This is an asynchronous method.

Reference: For the synchronous method, see getSelfIdsOnOtherPlatform().

Parameters
callback- Returns the unique selfID list on the other devices if the method succeeds.
  • Returns the description of the cause of the error if the method fails.

◆ asyncRemoveUserFromBlackList()

void com.hyphenate.chat.EMContactManager.asyncRemoveUserFromBlackList ( final String  username,
final EMCallBack  callback 
)

Removes the contact from the blocklist.

Reference: For the synchronous method, see removeUserFromBlackList(String).

Parameters
usernameThe user to be removed from the blocklist.
callbackThe completion callback.
  • Success: The user is successfully removed from the blocklist.
  • Error: The user fails to be removed from the blocklist. The reason for the failure will be returned.

◆ asyncSaveBlackList()

void com.hyphenate.chat.EMContactManager.asyncSaveBlackList ( final List< String >  blackList,
final EMCallBack  callback 
)

Uploads the blocklist to server.

Reference: For the synchronous method, see saveBlackList(List).

Parameters
blackListThe blocklist.
callbackThe completion callback.
  • Success: The blocklist is uploaded to the server.
  • Error: The blocklist fails to be uploaded to the server. The reason for the failure will be returned.

◆ declineInvitation()

void com.hyphenate.chat.EMContactManager.declineInvitation ( String  username) throws HyphenateException

Declines a friend invitation.

This is a synchronous method and blocks the current thread.

Reference: For the asynchronous method, see asyncDeclineInvitation(String, EMCallBack).

Parameters
usernameThe user who initiates the invitation.

◆ deleteContact() [1/2]

void com.hyphenate.chat.EMContactManager.deleteContact ( String  username) throws HyphenateException

Deletes a contact and all the conversations associated.

This is a synchronous method and blocks the current thread.

Parameters
usernameThe contact to be deleted.
Exceptions
HyphenateExceptionA description of the issue that caused the exception.

◆ deleteContact() [2/2]

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.

Parameters
usernameThe user ID.
keepConversationWhether to keep the associated conversation and messages.
Exceptions
HyphenateExceptionA description of the issue that caused the exception.

◆ getAllContactsFromServer()

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.

Reference: For the asynchronous method, see asyncGetAllContactsFromServer(EMValueCallBack).

Returns
The list of contacts.
Exceptions
HyphenateExceptionA description of the exception.

◆ getBlackListFromServer()

List< String > com.hyphenate.chat.EMContactManager.getBlackListFromServer ( ) throws HyphenateException

Gets the blocklist from the server.

Reference: For the asynchronous method, see asyncGetBlackListFromServer(EMValueCallBack).

This is a synchronous method and blocks the current thread.

Returns
Returns the blocklist if the method succeeds.
Exceptions
HyphenateExceptionA description of the issue that caused the exception.

◆ getBlackListUsernames()

List< String > com.hyphenate.chat.EMContactManager.getBlackListUsernames ( )

Gets the local blocklist.

Returns
The blocklist.

◆ getContactsFromLocal()

List< String > com.hyphenate.chat.EMContactManager.getContactsFromLocal ( ) throws HyphenateException

Gets the contact list from the local database.

Returns
The contact list.
Exceptions
HyphenateExceptionA description of the issue that caused the exception.

◆ getSelfIdsOnOtherPlatform()

List< String > com.hyphenate.chat.EMContactManager.getSelfIdsOnOtherPlatform ( ) throws HyphenateException

Get the unique IDs of current user on the other devices. The ID is username + "/" + resource.

This is a synchronous method and blocks the current thread.

Reference: For the asynchronous method, see asyncGetSelfIdsOnOtherPlatform(EMValueCallBack).

Returns
Returns the unique device ID list on the other devices if the method succeeds.
Exceptions
HyphenateExceptionA description of the issue that caused this call to fail.

◆ removeContactListener()

void com.hyphenate.chat.EMContactManager.removeContactListener ( EMContactListener  contactListener)

Removes the contact listener.

Reference: Adds the contact listener by calling setContactListener(EMContactListener).

◆ removeUserFromBlackList()

void com.hyphenate.chat.EMContactManager.removeUserFromBlackList ( String  username) throws HyphenateException

Removes the contact from the blocklist.

Reference: For the asynchronous method, see asyncRemoveUserFromBlackList(String, EMCallBack).

This is a synchronous method and blocks the current thread.

Parameters
usernameThe user to be removed from the blocklist.
Exceptions
HyphenateExceptionA description of the exception.

◆ saveBlackList()

void com.hyphenate.chat.EMContactManager.saveBlackList ( List< String >  blackList) throws HyphenateException

Uploads the blocklist to server.

This is a synchronous method and blocks the current thread.

Reference: For the asynchronous method, see asyncSaveBlackList(List, EMCallBack).

Parameters
blackListThe blocklist.

◆ setContactListener()

void com.hyphenate.chat.EMContactManager.setContactListener ( EMContactListener  contactListener)

Registers a new contact listener.

Reference: Call removeContactListener(EMContactListener) to remove the listener.

Parameters
contactListenerThe contact listener to be registered.

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