hyphenate_SDK4.0 5.0.0
hyphenate java IM SDK
 
Loading...
Searching...
No Matches
com.hyphenate.chat.EMChatManager Class Reference

Classes

enum  AttachmentDownloadType
 

Public Member Functions

void sendMessage (final EMMessage msg)
 
void asyncSendMessageReadReceipts (final List< EMMessage > messages, final EMCallBack callBack)
 
void asyncClearConversationUnreadMessageCount (final String conversationId, final EMCallBack callBack)
 
void recallMessage (EMMessage message) throws HyphenateException
 
void asyncRecallMessage (final EMMessage message, final EMCallBack callback)
 
void recallMessage (EMMessage message, String ext) throws HyphenateException
 
void asyncRecallMessage (final EMMessage message, String ext, final EMCallBack callback)
 
EMMessage getMessage (String messageId)
 
void asyncLoadMessages (@NonNull List< String > messageIds, @NonNull String conversationId, final EMValueCallBack< List< EMMessage > > callback)
 
EMConversation getConversation (String id)
 
EMConversation getConversation (String id, EMConversationType type)
 
EMConversation getConversation (String username, EMConversationType type, boolean createIfNotExists)
 
EMConversation getConversation (String username, EMConversationType type, boolean createIfNotExists, boolean isChatThread)
 
void asyncClearAllConversationUnreadMessageCount (final EMCallBack callBack)
 
int getUnreadMessageCount ()
 
void saveMessage (EMMessage message)
 
boolean updateMessage (EMMessage message)
 
void asyncModifyMessage (String messageId, @Nullable EMMessageBody messageBodyModified, @Nullable Map< String, Object > ext, final EMValueCallBack< EMMessage > callBack)
 
void downloadAttachment (final EMMessage msg)
 
void downloadAttachment (final EMMessage msg, @Nullable final EMCallBack callback)
 
void downloadBigImage (final EMMessage msg, @Nullable final EMCallBack callback)
 
void downloadThumbnail (final EMMessage msg, @Nullable final EMCallBack callback)
 
void downloadThumbnail (final EMMessage msg)
 
void downloadAndParseCombineMessage (EMMessage message, EMValueCallBack< List< EMMessage > > callback)
 
synchronized void importMessages (List< EMMessage > msgs)
 
List< EMConversationgetConversationsByType (EMConversationType type)
 
Map< String, EMConversationgetAllConversations ()
 
List< EMConversationgetAllConversationsBySort ()
 
void asyncFilterConversationsFromDB (EMCustomConversationFilter filter, boolean cleanConversationsCache, EMValueCallBack< List< EMConversation > > callBack)
 
void cleanConversationsMemoryCache ()
 
void asyncPinConversation (final String conversationId, boolean isPinned, final EMCallBack callback)
 
boolean deleteConversation (String conversationId, boolean deleteMessages)
 
void asyncDeleteConversations (List< String > conversationIds, boolean deleteMessages, EMCallBack callBack)
 
void deleteConversationFromServer (String username, EMConversationType type, boolean isDeleteServerMessages, EMCallBack deleteCallBack)
 
void addMessageListener (EMMessageListener listener)
 
void removeMessageListener (EMMessageListener listener)
 
void addConversationListener (EMConversationListener listener)
 
void removeConversationListener (EMConversationListener listener)
 
void setVoiceMessageListened (EMMessage message)
 
void asyncFetchGroupMessageReadReceipts (final String msgId, final int pageSize, final String startAckId, final EMValueCallBack< EMCursorResult< EMGroupReadReceipt > > callBack)
 
void asyncGetGroupMessageReadReceipts (final List< EMMessage > messages, final EMValueCallBack< List< EMMessageReadReceipt > > callBack)
 
void asyncFetchHistoryMessages (String conversationId, EMConversationType type, int pageSize, String cursor, EMFetchMessageOption option, final EMValueCallBack< EMCursorResult< EMMessage > > callBack)
 
void asyncSearchMessagesFromServer (@NonNull final EMMessageSearchOption option, final int pageSize, final int pageNum, final EMValueCallBack< EMPageResult< EMSearchServerMessageResult > > callBack)
 
List< EMMessagesearchMsgFromDB (@NonNull Type type, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction)
 
List< EMMessagesearchMsgFromDB (Set< Type > types, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction)
 
List< EMMessagesearchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction)
 
List< EMMessagesearchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction, EMConversation.EMMessageSearchScope searchScope)
 
void asyncLoadConversationMessagesWithKeyword (String keyword, long timestamp, String sender, EMConversation.EMSearchDirection direction, EMConversation.EMMessageSearchScope scope, EMValueCallBack< Map< String, List< String > > > callBack)
 
void deleteMessagesBeforeTimestamp (long timeStamp, EMCallBack callback)
 
void fetchSupportLanguages (EMValueCallBack< List< EMLanguage > > callback)
 
void translateMessage (EMMessage message, List< String > languages, EMValueCallBack< EMMessage > callback)
 
void voiceMessageToText (final EMMessage message, final EMValueCallBack< String > callback)
 
void voiceFileToText (final String filePath, final EMAudioParams audioParams, final EMValueCallBack< String > callback)
 
void addReaction (final String messageId, final String reaction) throws HyphenateException
 
void asyncAddReaction (final String messageId, final String reaction, final EMCallBack callback)
 
void removeReaction (final String messageId, final String reaction) throws HyphenateException
 
void asyncRemoveReaction (final String messageId, final String reaction, final EMCallBack callback)
 
Map< String, List< EMMessageReaction > > getReactionList (final List< String > messageIdList, final EMMessage.ChatType chatType, final String groupId) throws HyphenateException
 
void asyncGetReactionList (final List< String > messageIdList, final EMMessage.ChatType chatType, final String groupId, final EMValueCallBack< Map< String, List< EMMessageReaction > > > callback)
 
EMCursorResult< EMMessageReactiongetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize) throws HyphenateException
 
void asyncGetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize, final EMValueCallBack< EMCursorResult< EMMessageReaction > > callback)
 
void asyncAddConversationMark (@NonNull List< String > conversationIds, @NonNull EMMarkType mark, EMCallBack callback)
 
void asyncRemoveConversationMark (@NonNull List< String > conversationIds, @NonNull EMMarkType mark, EMCallBack callback)
 
void asyncDeleteAllMsgsAndConversations (boolean clearSeverData, EMCallBack deleteCallBack)
 
void asyncPinMessage (@NonNull String messageId, EMCallBack callBack)
 
void asyncUnPinMessage (@NonNull String messageId, EMCallBack callBack)
 
void asyncGetPinnedMessagesFromServer (@NonNull String conversationId, EMValueCallBack< List< EMMessage > > callBack)
 
void asyncGetMessageCount (EMValueCallBack< Integer > callBack)
 

Protected Member Functions

void removeMessagesFromServer (String conversationId, EMConversationType type, List< String > msgIdList, EMCallBack callBack)
 
void removeMessagesFromServer (String conversationId, EMConversationType type, long beforeTimeStamp, EMCallBack callBack)
 

Detailed Description

The chat manager class, responsible for sending and receiving messages, managing conversations (including loading and deleting conversations), and downloading attachments.

The sample code for sending a text message is as follows:

EMMessage message = EMMessage.createTextSendMessage(content, toChatUsername);
EMClient.getInstance().chatManager().sendMessage(message);
void sendMessage(final EMMessage msg)
Definition EMChatManager.java:783
Definition EMClient.java:100
Definition EMMessage.java:99
static EMMessage createTextSendMessage(String content, String username)
Definition EMMessage.java:736

Member Function Documentation

◆ addConversationListener()

void com.hyphenate.chat.EMChatManager.addConversationListener ( EMConversationListener listener)

Adds the conversation listener.

After a conversation listener is added, you can listen for conversation changes.

You can call the removeConversationListener(EMConversationListener) method to remove the conversation listener when it is not required.

Parameters
listenerThe conversation listener to add. See EMConversationListener.

◆ addMessageListener()

void com.hyphenate.chat.EMChatManager.addMessageListener ( EMMessageListener listener)

Adds the message listener.

After a message listener is added, you can listen for new messages when they arrive.

You can call removeMessageListener(EMMessageListener) to remove the message listener when it is not required.

Parameters
listenerThe message listener to add. See EMMessageListener.

◆ addReaction()

void com.hyphenate.chat.EMChatManager.addReaction ( final String messageId,
final String reaction ) throws HyphenateException

Adds a Reaction.

This is a synchronous method.

Parameters
messageIdThe message ID.
reactionThe Reaction content.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ asyncAddConversationMark()

void com.hyphenate.chat.EMChatManager.asyncAddConversationMark ( @NonNull List< String > conversationIds,
@NonNull EMMarkType mark,
EMCallBack callback )

Marks conversations.

This method marks conversations both locally and on the server.

Parameters
conversationIdsThe list of conversation IDs.
markThe mark to add for the conversations.
callbackThe completion callback, which contains the description of the cause to the failure.

◆ asyncAddReaction()

void com.hyphenate.chat.EMChatManager.asyncAddReaction ( final String messageId,
final String reaction,
final EMCallBack callback )

Adds a Reaction.

This is an asynchronous method.

Parameters
messageIdThe message ID.
reactionThe message Reaction to add.
callbackThe result callback which contains the error information if the method fails. See EMCallBack.

◆ asyncClearAllConversationUnreadMessageCount()

void com.hyphenate.chat.EMChatManager.asyncClearAllConversationUnreadMessageCount ( final EMCallBack callBack)

Clears the unread message count of all conversations.

The local unread count of all conversations is cleared to zero and synced to the current user's other devices.

This is an asynchronous method.

Parameters
callBackThe result callback. See EMCallBack.

◆ asyncClearConversationUnreadMessageCount()

void com.hyphenate.chat.EMChatManager.asyncClearConversationUnreadMessageCount ( final String conversationId,
final EMCallBack callBack )

Clears the unread message count of a conversation.

The local unread count is cleared to zero and synced to the current user's other devices. This method does not send a read receipt to the peer.

This is an asynchronous method.

Parameters
conversationIdThe conversation ID.
callBackThe result callback. See EMCallBack.

◆ asyncDeleteAllMsgsAndConversations()

void com.hyphenate.chat.EMChatManager.asyncDeleteAllMsgsAndConversations ( boolean clearSeverData,
EMCallBack deleteCallBack )

Clears all conversations and all messages in them.

This is an asynchronous method.

Parameters
clearSeverDataWhether to clear all conversations and all messages in them on the server.
  • true:Yes. All conversations and all messages in them will be cleared on the server side. The current user cannot retrieve messages and conversations from the server, while this has no impact on other users.
  • (Default) false:No. All local conversations and all messages in them will be cleared, while those on the server remain.
deleteCallBackThe completion callback, which contains the description of the cause to the failure.

◆ asyncDeleteConversations()

void com.hyphenate.chat.EMChatManager.asyncDeleteConversations ( List< String > conversationIds,
boolean deleteMessages,
EMCallBack callBack )

Deletes multiple local conversations.

This is an asynchronous method.

Parameters
conversationIdsThe list of conversation IDs to delete.
deleteMessagesWhether to delete the historical messages with the conversations.
  • true: Yes.
  • false: No.
callBackThe completion callback. If this call succeeds, calls EMCallBack#onSuccess(); if this call fails, calls EMCallBack#onError(int, String).

◆ asyncFetchGroupMessageReadReceipts()

void com.hyphenate.chat.EMChatManager.asyncFetchGroupMessageReadReceipts ( final String msgId,
final int pageSize,
final String startAckId,
final EMValueCallBack< EMCursorResult< EMGroupReadReceipt > > callBack )

Uses the pagination to get read receipts for the group message from the server.

To send a read receipt for a group message, you can call asyncSendMessageReadReceipts(List, EMCallBack).

This is an asynchronous method.

Parameters
msgIdThe message ID.
pageSizeThe number of read receipts for the group message that you expect to get on each page. The value range is [1,50].
startAckIdThe starting read receipt ID for query. After this parameter is set, the SDK retrieves read receipts, from the specified one, in the reverse chronological order of when the server receives them. If this parameter is set as null or an empty string, the SDK retrieves read receipts, from the latest one, in the reverse chronological order of when the server receives them.
callBackThe result callback:

◆ asyncFetchHistoryMessages()

void com.hyphenate.chat.EMChatManager.asyncFetchHistoryMessages ( String conversationId,
EMConversationType type,
int pageSize,
String cursor,
EMFetchMessageOption option,
final EMValueCallBack< EMCursorResult< EMMessage > > callBack )

Uses the pagination to get the messages in the conversation from the server according to the message pulling parameter configuration class (EMFetchMessageOption).

This is an asynchronous method.

Parameters
conversationIdThe conversation ID.
  • One-to-one chat: The ID of the peer user.
  • Group chat: The group ID.
  • Chat room: The chat room ID.
typeThe conversation type. See EMConversationType.
pageSizeThe number of messages you expect to get on each page. The value range is [1,50].
cursorThe cursor position from which to start querying data.
optionThe parameter configuration class for querying historical messages. See EMFetchMessageOption.
Returns
The list of retrieved messages and the cursor for the next query.
Parameters
callBackThe result callback:

◆ asyncFilterConversationsFromDB()

void com.hyphenate.chat.EMChatManager.asyncFilterConversationsFromDB ( EMCustomConversationFilter filter,
boolean cleanConversationsCache,
EMValueCallBack< List< EMConversation > > callBack )

Gets local conversations by the custom conversation filter.

The SDK loads conversations from the local database by the specified filter conditions.

This is an asynchronous method.

Parameters
filterThe filter. See EMCustomConversationFilter. If you want to get all conversations, pass in null.
cleanConversationsCacheWhether to clear the cached conversations in memory:
  • true: Yes.
  • false: No.
callBackThe completion callback. If this call succeeds, calls EMValueCallBack#onSuccess(Object) and returns the list of filtered conversation.

◆ asyncGetGroupMessageReadReceipts()

void com.hyphenate.chat.EMChatManager.asyncGetGroupMessageReadReceipts ( final List< EMMessage > messages,
final EMValueCallBack< List< EMMessageReadReceipt > > callBack )

Gets the read receipt details for a batch of messages from the server.

This is an asynchronous method.

Parameters
messagesThe message list. Maximum 20 messages. Must belong to the same conversation.
callBackThe result callback:

◆ asyncGetMessageCount()

void com.hyphenate.chat.EMChatManager.asyncGetMessageCount ( EMValueCallBack< Integer > callBack)

Gets the total count of messages in the local database.

This is an asynchronous method.

Parameters
callBackThe completion callback. If the call succeeds, the total count of messages in the local database is returned. If the call fails, the cause of the failure is returned.

◆ asyncGetPinnedMessagesFromServer()

void com.hyphenate.chat.EMChatManager.asyncGetPinnedMessagesFromServer ( @NonNull String conversationId,
EMValueCallBack< List< EMMessage > > callBack )

Gets the list of pinned messages from the server.

This is an asynchronous method.

Parameters
conversationIdThe conversation ID.
callBackThe completion callback. If the call succeeds, the list of pinned messages in the conversation are returned. If the call fails, the cause of the failure is returned.

◆ asyncGetReactionDetail()

void com.hyphenate.chat.EMChatManager.asyncGetReactionDetail ( final String messageId,
final String reaction,
final String cursor,
final int pageSize,
final EMValueCallBack< EMCursorResult< EMMessageReaction > > callback )

Gets the Reaction details.

This is an asynchronous method.

Parameters
messageIdThe message ID.
reactionThe Reaction content.
cursorThe cursor position from which to start querying data.
pageSizeThe number of Reactions you expect to get on each page.
callbackThe query result EMCursorResult, which contains the cursor for the next query and EMMessageReaction list (only the first data entry is used).

◆ asyncGetReactionList()

void com.hyphenate.chat.EMChatManager.asyncGetReactionList ( final List< String > messageIdList,
final EMMessage.ChatType chatType,
final String groupId,
final EMValueCallBack< Map< String, List< EMMessageReaction > > > callback )

Gets the list of Reactions.

This is an asynchronous method.

Parameters
messageIdListThe message ID.
chatTypeThe conversation type. Only one-to-one chats (EMMessage.ChatType#Chat and group chats (EMMessage.ChatType#GroupChat) are allowed.
groupIdThe group ID, which is valid only for group chats.
callbackThe Reaction list under the specified message ID. The UserList of EMMessageReaction indicates the summary data, which only contains the information of the first three users.

◆ asyncLoadConversationMessagesWithKeyword()

void com.hyphenate.chat.EMChatManager.asyncLoadConversationMessagesWithKeyword ( String keyword,
long timestamp,
String sender,
EMConversation.EMSearchDirection direction,
EMConversation.EMMessageSearchScope scope,
EMValueCallBack< Map< String, List< String > > > callBack )

Retrieves messages with keywords from the local database.

The SDK returns messages, including the mapping between the conversation ID and message ID ordered by the specified direction.

Parameters
keywordThe keywords for query. Setting to null ignores this parameter.
timestampThe starting UNIX timestamp in the message for query. The unit is millisecond. If this parameter is set to a negative value, the SDK retrieves messages from the latest one backward.
senderThe message sender. Setting to null ignores this parameter.
directionThe message search direction. See EMConversation.EMSearchDirection.
  • (Default) UP: Messages are retrieved in the descending order of timestamp.
  • DOWN: Messages are retrieved in the ascending order of timestamp.
scopeThe message search scope. See EMConversation.EMMessageSearchScope.
callBackThe completion callback. If this call succeeds, EMValueCallBack#onSuccess(Map<String,List<String>>) returns a mapping where the key is the conversation ID and the value is a list of message IDs ordered by the specified direction.

If this call fails, it contains the reason for the failure.

◆ asyncLoadMessages()

void com.hyphenate.chat.EMChatManager.asyncLoadMessages ( @NonNull List< String > messageIds,
@NonNull String conversationId,
final EMValueCallBack< List< EMMessage > > callback )

Retrieves messages with specified IDs from the local database.

This method retrieves a maximum of 20 messages each time, and the messages are sorted in the reverse chronological order.

Parameters
messageIdsThe message ID list which can contain up to 20 message IDs. It cannot be null.
conversationIdThe conversation ID. This parameter cannot be null or an empty string.
callbackThe completion callback. If this call succeeds, the returned list contains message objects with the specified IDs. If this method call fails, it contains the reason for the failure.

◆ asyncModifyMessage()

void com.hyphenate.chat.EMChatManager.asyncModifyMessage ( String messageId,
@Nullable EMMessageBody messageBodyModified,
@Nullable Map< String, Object > ext,
final EMValueCallBack< EMMessage > callBack )

Modify the local and server message.

  • Text/Custom message: Support modifying the message content (body) and extension ext.
  • File/Video/Audio/Image/Location/Combine forward message: Only support modifying the message extension ext.
  • Command message: Not supported.

This method will update the message on the server and locally at the same time, and the message ID will not be updated.

The recipient(s) and multi-device login scenarios can listen for message changes through the callback EMMessageListener#onMessageContentChanged(EMMessage, String, long).

Parameters
messageIdThe ID of the message.
messageBodyModifiedThe message body after modification. Only text messages and custom messages are supported. Pass null to indicate no modification.
extThe modified message extension, Map type, the generic type is <String, Object>, where Object supports the following types: {String.class, Integer.class, Double.class, Boolean.class, Long.class, Float.class, JSONObject.class, JSONArray.class}. It will overwrite the previous extension information. Pass null to indicate no modification.
callBackThe callback for whether the message modification is successful. The object of the EMValueCallBack class, see EMValueCallBack, contains the modified message object.

◆ asyncPinConversation()

void com.hyphenate.chat.EMChatManager.asyncPinConversation ( final String conversationId,
boolean isPinned,
final EMCallBack callback )

Sets whether to pin a conversation.

Parameters
conversationIdThe conversation ID.
isPinnedWhether to pin the conversation:
  • true:Yes.
  • false: No. The conversation is unpinned.
callbackThe callback for setting whether to pin the conversation.

◆ asyncPinMessage()

void com.hyphenate.chat.EMChatManager.asyncPinMessage ( @NonNull String messageId,
EMCallBack callBack )

Pins a message.

This is an asynchronous method.

Parameters
messageIdThe ID of the message to be pinned.
callBackThe completion callback, which contains the description of the cause to the failure.

◆ asyncRecallMessage() [1/2]

void com.hyphenate.chat.EMChatManager.asyncRecallMessage ( final EMMessage message,
final EMCallBack callback )

Recalls the sent message.

This is an asynchronous method.

Parameters
messageThe message object.
callbackA object of the EMCallBack class. See EMCallBack.

◆ asyncRecallMessage() [2/2]

void com.hyphenate.chat.EMChatManager.asyncRecallMessage ( final EMMessage message,
String ext,
final EMCallBack callback )

Recalls the sent message.

This is an asynchronous method.

Parameters
messageThe message object.
extThe extended information.
callbackA object of the EMCallBack class. See EMCallBack.

◆ asyncRemoveConversationMark()

void com.hyphenate.chat.EMChatManager.asyncRemoveConversationMark ( @NonNull List< String > conversationIds,
@NonNull EMMarkType mark,
EMCallBack callback )

Unmarks conversations.

This method unmarks conversations both locally and on the server.

Parameters
conversationIdsThe list of conversation IDs.
markThe conversation mark to remove.
callbackThe completion callback, which contains the description of the cause to the failure.

◆ asyncRemoveReaction()

void com.hyphenate.chat.EMChatManager.asyncRemoveReaction ( final String messageId,
final String reaction,
final EMCallBack callback )

Deletes a Reaction.

This is an asynchronous method.

Parameters
messageIdThe message ID.
reactionThe Reaction to delete.
callbackThe result callback which contains the error information if the method fails. See EMCallBack.

◆ asyncSearchMessagesFromServer()

void com.hyphenate.chat.EMChatManager.asyncSearchMessagesFromServer ( @NonNull final EMMessageSearchOption option,
final int pageSize,
final int pageNum,
final EMValueCallBack< EMPageResult< EMSearchServerMessageResult > > callBack )

Searches messages from the server. This feature requires the Message Search value-added service to be enabled in the Console.

Parameters
optionThe search option. See EMMessageSearchOption.
pageSizeResults per page. The value range is [1,100].
pageNumThe page number for pagination, starting from 1.
callBackThe completion callback, which contains the search result or error. The search result is sorted by relevance.

◆ asyncSendMessageReadReceipts()

void com.hyphenate.chat.EMChatManager.asyncSendMessageReadReceipts ( final List< EMMessage > messages,
final EMCallBack callBack )

Sends read receipts for messages in batch.

This method is used for both one-to-one and group chats. All messages must belong to the same conversation. This method does not change the unread message count of the conversation. The EMMessage#isNeedReadReceipt() property of the messages must be true.

This is an asynchronous method.

Parameters
messagesThe message list. Maximum 50 messages. Messages that do not need a receipt or are already acknowledged are skipped. A batch without eligible messages is a no-op.
callBackThe result callback:

◆ asyncUnPinMessage()

void com.hyphenate.chat.EMChatManager.asyncUnPinMessage ( @NonNull String messageId,
EMCallBack callBack )

Unpins a message.

This is an asynchronous method.

Parameters
messageIdThe ID of the message to be unpinned.
callBackThe completion callback, which contains the description of the cause to the failure.

◆ cleanConversationsMemoryCache()

void com.hyphenate.chat.EMChatManager.cleanConversationsMemoryCache ( )

Clears all conversations in memory to release the memory.

Note: After releasing the memory, you cannot get any conversations by calling getAllConversations() or getAllConversationsBySort(). Also, if you call getUnreadMessageCount() in this case, the returned number of unread messages is 0.

If you want to retrieve all conversations and the number of unread messages, you need to call loadAllConversations() or asyncFilterConversationsFromDB(EMCustomConversationFilter, boolean, EMValueCallBack) to reload the conversations from the database into memory first.

◆ deleteConversation()

boolean com.hyphenate.chat.EMChatManager.deleteConversation ( String conversationId,
boolean deleteMessages )

Deletes a conversation and its local messages from the local database.

Parameters
conversationIdThe conversation ID.
deleteMessagesWhether to delete the historical messages with the conversation.
  • true: Yes.
  • false: No.
Returns
Whether the conversation is successfully deleted.
  • true: Yes.
  • false: No.

◆ deleteConversationFromServer()

void com.hyphenate.chat.EMChatManager.deleteConversationFromServer ( String username,
EMConversationType type,
boolean isDeleteServerMessages,
EMCallBack deleteCallBack )

Deletes the specified conversation and its historical messages from the server and local.

This is an asynchronous method.

Parameters
usernameThe conversation ID.
typeThe conversation type. See EMConversationType.
isDeleteServerMessagesWhether to delete the historical messages with the conversation.
  • true: Yes
  • false: No
deleteCallBackThe callback for the deletion of the conversation and its historical messages.
  • true: Success;
  • false: Failure.

◆ deleteMessagesBeforeTimestamp()

void com.hyphenate.chat.EMChatManager.deleteMessagesBeforeTimestamp ( long timeStamp,
EMCallBack callback )

Deletes local historical messages with a Unix timestamp before a specified one.

Parameters
timeStampThe starting Unix timestamp in the message for query. This unit is millisecond.
callbackThe result callback. See EMCallBack.

◆ downloadAndParseCombineMessage()

void com.hyphenate.chat.EMChatManager.downloadAndParseCombineMessage ( EMMessage message,
EMValueCallBack< List< EMMessage > > callback )

Downloads and parses the attachment of the combined message.

For a combined message, this method downloads and parses the attachment and returns the message list at the first call; for subsequent calls, there are two cases: 1.If the attachment already exits, this method directly parses it and returns the message list. 2.If the attachment does not exist, this method downloads it before parsing it and returning the message list.

Parameters
messageThe combined message to download and parse.
callbackThe completion callback. If this call succeeds, calls EMValueCallBack#onSuccess(Object) and returns the parsed message list; If this call fails, calls EMValueCallBack#onError(int, String).

◆ downloadAttachment() [1/2]

void com.hyphenate.chat.EMChatManager.downloadAttachment ( final EMMessage msg)

Downloads the message attachment.

You can also call this method if the attachment fails to be downloaded automatically.

Parameters
msgThe message object associated with the attachment to download.
Deprecated
Deprecated. Use downloadAttachment(EMMessage, EMCallBack) instead.

◆ downloadAttachment() [2/2]

void com.hyphenate.chat.EMChatManager.downloadAttachment ( final EMMessage msg,
@Nullable final EMCallBack callback )

Downloads the message attachment.

Parameters
msgThe message object associated with the attachment to download.
callbackThe download status callback. If not null, the SDK returns the result through EMCallBack#onProgress(int, String), EMCallBack#onSuccess(), and EMCallBack#onError(int, String).

◆ downloadBigImage()

void com.hyphenate.chat.EMChatManager.downloadBigImage ( final EMMessage msg,
@Nullable final EMCallBack callback )

Downloads the large image of an image message.

This method is only applicable to image messages.

Parameters
msgThe image message object associated with the large image to download.
callbackThe download status callback. If not null, the SDK returns the result through EMCallBack#onProgress(int, String), EMCallBack#onSuccess(), and EMCallBack#onError(int, String).

◆ downloadThumbnail() [1/2]

void com.hyphenate.chat.EMChatManager.downloadThumbnail ( final EMMessage msg)

Downloads the message thumbnail.

This method is only applicable to image and video messages.

Parameters
msgThe message object associated with the thumbnail to download.
Deprecated
Deprecated. Use downloadThumbnail(EMMessage, EMCallBack) instead.

◆ downloadThumbnail() [2/2]

void com.hyphenate.chat.EMChatManager.downloadThumbnail ( final EMMessage msg,
@Nullable final EMCallBack callback )

Downloads the message thumbnail.

This method is only applicable to image and video messages.

Parameters
msgThe message object associated with the thumbnail to download.
callbackThe download status callback. If not null, the SDK returns the result through EMCallBack#onProgress(int, String), EMCallBack#onSuccess(), and EMCallBack#onError(int, String).

◆ fetchSupportLanguages()

void com.hyphenate.chat.EMChatManager.fetchSupportLanguages ( EMValueCallBack< List< EMLanguage > > callback)

Gets all languages supported by the translation service.

Parameters
callbackThe result callback. See EMCallBack.

◆ getAllConversations()

Map< String, EMConversation > com.hyphenate.chat.EMChatManager.getAllConversations ( )

Gets all local conversations.

Conversations will be first retrieved from the memory. If no conversation is found, the SDK retrieves from the local database.

Returns
The retrieved conversations.

◆ getAllConversationsBySort()

List< EMConversation > com.hyphenate.chat.EMChatManager.getAllConversationsBySort ( )

Gets all local conversations.

Pinned conversations are listed at the top of the list and followed by unpinned conversations.

The SDK returns conversations in the descending order of the timestamp of the latest message in them, with the pinned ones at the top of the list and followed by the unpinned ones.

Conversations will be first retrieved from the memory. If no conversation is found, the SDK retrieves from the local database.

Returns
The sorted conversation list.

◆ getConversation() [1/4]

EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String id)

Gets the conversation object by conversation ID.

The SDK will return null if the conversation is not found.

Parameters
idThe conversation ID.
Returns
The conversation with the specified ID. The SDK returns null if the conversation is not found.

◆ getConversation() [2/4]

EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String id,
EMConversationType type )

Gets the conversation by conversation ID and type.

The SDK will return null if the conversation is not found.

Parameters
idThe conversation ID:
  • One-to-one chat: The ID of the peer user;
  • Group chat: The group ID;
  • Chat room chat: The chat room ID;
  • Message thread: The message thread ID.
typeThe conversation type. See EMConversationType
Returns
The conversation object found by ID and type. The SDK returns null if the conversation is not found.

◆ getConversation() [3/4]

EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String username,
EMConversationType type,
boolean createIfNotExists )

Gets the conversation object by user ID or group ID and conversation type.

Parameters
usernameThe conversation ID:
  • One-to-one chat: The ID of the peer user;
  • Group chat: The group ID;
  • Chat room chat: The chat room ID;
  • Message thread: The message thread ID.
typeThe conversation type. See EMConversationType.
createIfNotExistsWhether to create a conversation if the specified conversation is not found:
  • true: Yes;
  • false: No.
Returns
The retrieved conversation object. The SDK returns null if the conversation is not found.

◆ getConversation() [4/4]

EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String username,
EMConversationType type,
boolean createIfNotExists,
boolean isChatThread )

Get conversation object by conversation id and conversation type.

If the conversation is not found, you can create a new object based on the value of CreateIFNotExists or an empty object.

Parameters
usernameThe conversation ID.
  • One-to-one chat: The ID of the peer user;
  • Group chat: The group ID;
  • Chat room chat: The chat room ID;
  • Message thread: The message thread ID.
typeThe conversation type. See EMConversationType.
createIfNotExistsWhether to create a conversation if the specified conversation is not found:
  • true: Yes;
  • false: No.
isChatThreadWhether to search for the chat thread conversation.
  • true: Yes;
  • false: No.
Returns
The retrieved conversation object. The SDK returns null if the conversation is not found.

◆ getConversationsByType()

List< EMConversation > com.hyphenate.chat.EMChatManager.getConversationsByType ( EMConversationType type)

Gets the list of conversations by conversation type.

Parameters
typeThe conversation type. See EMConversationType.
Returns
The list of conversations of the specified type.

◆ getMessage()

EMMessage com.hyphenate.chat.EMChatManager.getMessage ( String messageId)

Gets the message by message ID.

Parameters
messageIdThe message ID.
Returns
The message object with the specified ID. The SDK returns null if the message does not exist.

◆ getReactionDetail()

EMCursorResult< EMMessageReaction > com.hyphenate.chat.EMChatManager.getReactionDetail ( final String messageId,
final String reaction,
final String cursor,
final int pageSize ) throws HyphenateException

Gets the Reaction details.

This is a synchronous method.

Parameters
messageIdThe message ID.
reactionThe Reaction content.
cursorThe cursor position from which to start querying data.
pageSizeThe number of Reactions you expect to get on each page.
Returns
The query result EMCursorResult, which contains the list of obtained Reactions and the cursor for the next query. If the cursor is null, all data is obtained.
Exceptions
HyphenateExceptionA description of the exception, see EMError.

◆ getReactionList()

Map< String, List< EMMessageReaction > > com.hyphenate.chat.EMChatManager.getReactionList ( final List< String > messageIdList,
final EMMessage.ChatType chatType,
final String groupId ) throws HyphenateException

Gets the list of Reactions.

This is a synchronous method.

Parameters
messageIdListThe message ID.
chatTypeThe conversation type. Only the one-to-one chats (EMMessage.ChatType#Chat and group chats (EMMessage.ChatType#GroupChat) are allowed.
groupIdThe group ID, which is invalid only for group chats.
Returns
map The Reaction list under the specified message ID. The UserList of EMMessageReaction indicates the summary data, which only contains the information of the first three users.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getUnreadMessageCount()

int com.hyphenate.chat.EMChatManager.getUnreadMessageCount ( )

Gets the unread message count.

Muted conversations (whose remind type is not EMPushManager.EMPushRemindType#ALL) are excluded.

Returns
The count of unread messages.

◆ importMessages()

synchronized void com.hyphenate.chat.EMChatManager.importMessages ( List< EMMessage > msgs)

Imports messages to the local database.

You can only import messages that you sent or received.

It is recommended that you import at most 1,000 messages each time.

Parameters
msgsThe messages to import.

◆ recallMessage() [1/2]

void com.hyphenate.chat.EMChatManager.recallMessage ( EMMessage message) throws HyphenateException

Recalls the sent message.

If the recipient is offline when the message is delivered and recalled, the recipient only receives the callback EMMessageListener#onMessageRecalled instead of the message.

This is a synchronous method and blocks the current thread.

Parameters
messageThe message instance.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ recallMessage() [2/2]

void com.hyphenate.chat.EMChatManager.recallMessage ( EMMessage message,
String ext ) throws HyphenateException

Recalls the sent message.

If the recipient is offline when the message is delivered and recalled, the recipient only receives the callback EMMessageListener#onMessageRecalled instead of the message.

This is a synchronous method and blocks the current thread.

Parameters
messageThe message instance.
extExtended Information
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ removeConversationListener()

void com.hyphenate.chat.EMChatManager.removeConversationListener ( EMConversationListener listener)

Removes the conversation listener.

After adding a conversation listener with addConversationListener(EMConversationListener), you can call this method to remove it when it is not required.

Parameters
listenerThe conversation listener to remove.

◆ removeMessageListener()

void com.hyphenate.chat.EMChatManager.removeMessageListener ( EMMessageListener listener)

Removes the message listener.

After adding a message listener with addMessageListener(EMMessageListener), you can call this method to remove it when it is not required.

Parameters
listenerThe message listener to remove.

◆ removeMessagesFromServer() [1/2]

void com.hyphenate.chat.EMChatManager.removeMessagesFromServer ( String conversationId,
EMConversationType type,
List< String > msgIdList,
EMCallBack callBack )
protected

Unidirectionally removes historical message by message ID from the server.

Parameters
conversationIdThe conversation ID.
typeThe conversation type.
msgIdListThe list of IDs of messages to be removed.
callBackThe result callback which contains the error information if the method fails. See EMCallBack.

◆ removeMessagesFromServer() [2/2]

void com.hyphenate.chat.EMChatManager.removeMessagesFromServer ( String conversationId,
EMConversationType type,
long beforeTimeStamp,
EMCallBack callBack )
protected

Unidirectionally removes historical message by timestamp from the server.

Parameters
conversationIdThe conversation ID.
typeThe conversation type.
beforeTimeStampThe UNIX timestamp in millisecond. Messages with a timestamp smaller than the specified one will be removed.
callBackThe result callback which contains the error information if the method fails. See EMCallBack.

◆ removeReaction()

void com.hyphenate.chat.EMChatManager.removeReaction ( final String messageId,
final String reaction ) throws HyphenateException

Deletes a Reaction.

This is a synchronous method.

Parameters
messageIdThe message ID.
reactionThe Reaction content to delete.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ saveMessage()

void com.hyphenate.chat.EMChatManager.saveMessage ( EMMessage message)

Saves the message to the memory and local database.

The command messages (type: Type#CMD, message body: EMCmdMessageBody) are not saved locally.

Parameters
messageThe message to store.

◆ searchMsgFromDB() [1/4]

List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB ( @NonNull Type type,
long timeStamp,
int maxCount,
String from,
EMConversation.EMSearchDirection direction )

Retrieves messages of a certain type from the local database.

Parameters
typeThe message type. See Type.
timeStampThe starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them.
maxCountThe maximum number of messages to retrieve each time. The value range is [1,400].
fromThe user ID of the message sender. If this parameter is set to null or an empty string, there is no restriction on the message sender during message search.
directionThe message search direction. See EMConversation.EMSearchDirection.
  • (Default) UP: The SDK retrieves messages in the descending order of the timestamp included in them.
  • DOWN: The SDK retrieves messages in the ascending order of the timestamp included in them.
Returns
The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned.

◆ searchMsgFromDB() [2/4]

List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB ( Set< Type > types,
long timeStamp,
int maxCount,
String from,
EMConversation.EMSearchDirection direction )

Retrieves messages of multiple types in the conversation from the local database.

Parameters
typesThe message types. See Type.
timeStampThe starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them.
maxCountThe maximum number of messages to retrieve each time. The value range is [1,400].
fromThe user ID of the message sender. If this parameter is set to null or an empty string, there is no restriction on the message sender during message search.
directionThe message search direction. See EMConversation.EMSearchDirection.
  • (Default) UP: The SDK retrieves messages in the descending order of the timestamp included in them.
  • DOWN: The SDK retrieves messages in the ascending order of the timestamp included in them.
Returns
The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned.

◆ searchMsgFromDB() [3/4]

List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB ( String keywords,
long timeStamp,
int maxCount,
String from,
EMConversation.EMSearchDirection direction )

Retrieves messages with keywords in the local database.

Parameters
keywordsThe keywords for query.
timeStampThe starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them.
maxCountThe maximum number of messages to retrieve each time. The value range is [1,400].
fromThe user ID of the message sender. If this parameter is set to null or an empty string, there is no restriction on the message sender during message search.
directionThe message search direction. See EMConversation.EMSearchDirection.
  • (Default) UP: The SDK retrieves messages in the descending order of the timestamp included in them.
  • DOWN: The SDK retrieves messages in the ascending order of the timestamp included in them.
Returns
The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned.

◆ searchMsgFromDB() [4/4]

List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB ( String keywords,
long timeStamp,
int maxCount,
String from,
EMConversation.EMSearchDirection direction,
EMConversation.EMMessageSearchScope searchScope )

Retrieves messages with keywords from the local database.

Parameters
keywordsThe keywords for query.
timeStampThe starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them.
maxCountThe maximum number of messages to retrieve each time. The value range is [1,400]. If you set this parameter to 0 or less, the SDK gets one message from the local database.
fromThe user ID of the message sender. If this parameter is set to null or an empty string, there is no restriction on the message sender during message search.
directionThe message search direction. See EMConversation.EMSearchDirection.
  • (Default) UP: The SDK retrieves messages in the descending order of the timestamp included in them.
  • DOWN: The SDK retrieves messages in the ascending order of the timestamp included in them.
searchScopeThe message search scope. See EMConversation.EMMessageSearchScope.
Returns
The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned.

◆ sendMessage()

void com.hyphenate.chat.EMChatManager.sendMessage ( final EMMessage msg)

Sends a message。

For a voice or image message or a message with an attachment, the SDK will automatically upload the attachment.

You can determine whether to upload the attachment to the chat sever by setting EMOptions#setAutoTransferMessageAttachments(boolean).

To listen for the message sending status, call EMMessage#setMessageStatusCallback(EMCallBack).

Parameters
msgThe message object to be sent. Make sure to set the param.

◆ setVoiceMessageListened()

void com.hyphenate.chat.EMChatManager.setVoiceMessageListened ( EMMessage message)

Marks a voice message as listened.

Parameters
messageThe message object.

◆ translateMessage()

void com.hyphenate.chat.EMChatManager.translateMessage ( EMMessage message,
List< String > languages,
EMValueCallBack< EMMessage > callback )

Translates a text message.

Parameters
messageThe message object for translation.
languagesThe list of target language codes.
callbackThe result callback. See EMCallBack.

◆ updateMessage()

boolean com.hyphenate.chat.EMChatManager.updateMessage ( EMMessage message)

Updates the local message.

This method updates the message in both the memory and the local database at the same time.

Parameters
messageThe message object to update.

◆ voiceFileToText()

void com.hyphenate.chat.EMChatManager.voiceFileToText ( final String filePath,
final EMAudioParams audioParams,
final EMValueCallBack< String > callback )

Transcribes a local voice file into text.

Supported formats include EMAudioParams.AudioFormat#PCM, EMAudioParams.AudioFormat#MP3, and EMAudioParams.AudioFormat#AMR.

Parameters
filePathThe local path of the voice file.
audioParamsThe voice parameters.
Parameters
callbackThe result callback. Returns the converted text on success, or an error code and description on failure.

◆ voiceMessageToText()

void com.hyphenate.chat.EMChatManager.voiceMessageToText ( final EMMessage message,
final EMValueCallBack< String > callback )

Transcribes a voice message into text.

This method only supports successfully sent voice messages.

Once transcribed, the text is returned via callback and can also be retrieved through EMVoiceMessageBody#getText().

This method supports AMR and MP3 voice messages, but does not support direct transcription of PCM format.

Parameters
messageThe voice message object.
callbackThe result callback. Returns the transcribed text on success, or an error code and description on failure.

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