hyphenate_SDK4.0 4.8.0
hyphenate java IM SDK
|
Public Member Functions | |
void | sendMessage (final EMMessage msg) |
void | ackConversationRead (String conversationId) throws HyphenateException |
void | ackMessageRead (String to, String messageId) throws HyphenateException |
void | ackGroupMessageRead (String to, String messageId, String ext) throws HyphenateException |
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) |
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) |
boolean | markAllConversationsAsRead () |
int | getUnreadMessageCount () |
void | saveMessage (EMMessage message) |
boolean | updateMessage (EMMessage message) |
void | asyncModifyMessage (String messageId, EMMessageBody messageBodyModified, final EMValueCallBack< EMMessage > callBack) |
void | downloadAttachment (final EMMessage msg) |
void | downloadThumbnail (final EMMessage msg) |
void | downloadAndParseCombineMessage (EMMessage message, EMValueCallBack< List< EMMessage > > callback) |
synchronized void | importMessages (List< EMMessage > msgs) |
List< EMConversation > | getConversationsByType (EMConversationType type) |
Map< String, EMConversation > | getAllConversations () |
List< EMConversation > | getAllConversationsBySort () |
void | asyncFilterConversationsFromDB (EMCustomConversationFilter filter, boolean cleanConversationsCache, EMValueCallBack< List< EMConversation > > callBack) |
void | cleanConversationsMemoryCache () |
Map< String, EMConversation > | fetchConversationsFromServer () throws HyphenateException |
void | asyncFetchConversationsFromServer (final EMValueCallBack< Map< String, EMConversation > > callBack) |
void | asyncFetchConversationsFromServer (int pageNum, int pageSize, final EMValueCallBack< Map< String, EMConversation > > callBack) |
void | asyncFetchPinnedConversationsFromServer (final int limit, final String cursor, final EMValueCallBack< EMCursorResult< EMConversation > > callback) |
void | asyncFetchConversationsFromServer (final int limit, final String cursor, final EMValueCallBack< EMCursorResult< EMConversation > > callback) |
void | asyncPinConversation (final String conversationId, boolean isPinned, final EMCallBack callback) |
void | loadAllConversations () |
boolean | deleteConversation (String username, boolean deleteMessages) |
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) |
boolean | updateParticipant (String from, String changeTo) |
EMCursorResult< EMGroupReadAck > | fetchGroupReadAcks (String msgId, int pageSize, String startAckId) throws HyphenateException |
void | asyncFetchGroupReadAcks (final String msgId, final int pageSize, final String startAckId, final EMValueCallBack< EMCursorResult< EMGroupReadAck > > callBack) |
EMCursorResult< EMMessage > | fetchHistoryMessages (String conversationId, EMConversationType type, int pageSize, String startMsgId) throws HyphenateException |
EMCursorResult< EMMessage > | fetchHistoryMessages (String conversationId, EMConversationType type, int pageSize, String startMsgId, EMConversation.EMSearchDirection direction) throws HyphenateException |
void | asyncFetchHistoryMessage (final String conversationId, final EMConversationType type, final int pageSize, final String startMsgId, final EMValueCallBack< EMCursorResult< EMMessage > > callBack) |
void | asyncFetchHistoryMessage (final String conversationId, final EMConversationType type, final int pageSize, final String startMsgId, final EMConversation.EMSearchDirection direction, final EMValueCallBack< EMCursorResult< EMMessage > > callBack) |
void | asyncFetchHistoryMessages (String conversationId, EMConversationType type, int pageSize, String cursor, EMFetchMessageOption option, final EMValueCallBack< EMCursorResult< EMMessage > > callBack) |
List< EMMessage > | searchMsgFromDB (@NonNull Type type, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction) |
List< EMMessage > | searchMsgFromDB (Set< Type > types, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction) |
List< EMMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction) |
List< EMMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction, EMConversation.EMMessageSearchScope searchScope) |
void | deleteMessagesBeforeTimestamp (long timeStamp, EMCallBack callback) |
void | asyncReportMessage (String msgId, String tag, String reportReason, EMCallBack callback) |
void | reportMessage (String msgId, String tag, String reportReason) throws HyphenateException |
void | fetchSupportLanguages (EMValueCallBack< List< EMLanguage > > callback) |
void | translateMessage (EMMessage message, List< String > languages, EMValueCallBack< EMMessage > 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< EMMessageReaction > | getReactionDetail (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 | asyncGetConversationsFromServerWithCursor (@NonNull String cursor, @NonNull EMConversationFilter filter, EMValueCallBack< EMCursorResult< EMConversation > > 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) |
Protected Member Functions | |
void | removeMessagesFromServer (String conversationId, EMConversationType type, List< String > msgIdList, EMCallBack callBack) |
void | removeMessagesFromServer (String conversationId, EMConversationType type, long beforeTimeStamp, EMCallBack callBack) |
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:
void com.hyphenate.chat.EMChatManager.ackConversationRead | ( | String | conversationId | ) | throws HyphenateException |
Sends the conversation read receipt to the server.
This method is only for one-to-one chat conversations.
This method will inform the sever to set the unread message count of the conversation to 0
. The message sender will receive the EMConversationListener#onConversationRead(String, String) callback. The message recipient that has logged in to multiple devices, will also receive the callback.
If you want to send a read receipt for a group message, call ackGroupMessageRead(String, String, String).
conversationId | The conversation ID. |
HyphenateException | The possible exceptions are as follows: EMError#USER_NOT_LOGIN, EMError#SERVER_NOT_REACHABLE, and EMError#MESSAGE_INVALID. See EMError. |
void com.hyphenate.chat.EMChatManager.ackGroupMessageRead | ( | String | to, |
String | messageId, | ||
String | ext | ||
) | throws HyphenateException |
Sends the read receipt for a group message to the server.
Note
You can only call this method after setting EMOptions#setRequireAck(boolean) and EMMessage#setIsNeedGroupAck(boolean) to true
.
To send the read recipient for a one-to-one chat message to the server, call ackMessageRead(String, String).
To send the conversation read receipt to the server, call ackConversationRead(String).
to | The conversation ID. |
messageId | The message ID. |
ext | The extension information, which is a custom keyword that specifies a custom action or command. |
HyphenateException | A description of the exception, see EMError. |
void com.hyphenate.chat.EMChatManager.ackMessageRead | ( | String | to, |
String | messageId | ||
) | throws HyphenateException |
Sends the read receipt for a message to the server.
Note
This method applies to one-to-one chats only.
This method only takes effect if you set EMOptions#setRequireAck(boolean) as true
.
To send the read receipt for a group message, call ackGroupMessageRead(String, String, String).
We recommend that you call ackConversationRead(String) when opening the chat page, and call this method in other cases to reduce the number of method calls.
to | The recipient of the read receipt. |
messageId | The message ID. |
HyphenateException | A description of the exception, see EMError. |
void com.hyphenate.chat.EMChatManager.addConversationListener | ( | EMConversationListener | listener | ) |
Adds the conversation listener.
After a conversation listener is added, you can listen for conversation changes and conversation read receipts.
You can call the removeConversationListener(EMConversationListener) method to remove the conversation listener when it is not required.
listener | The conversation listener to add. See EMConversationListener. |
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.
listener | The message listener to add. See EMMessageListener. |
void com.hyphenate.chat.EMChatManager.addReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws HyphenateException |
Adds a Reaction.
This is a synchronous method.
messageId | The message ID. |
reaction | The Reaction content. |
HyphenateException | A description of the exception. See EMError. |
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.
conversationIds | The list of conversation IDs. |
mark | The mark to add for the conversations. |
callback | The completion callback, which contains the description of the cause to the failure. |
void com.hyphenate.chat.EMChatManager.asyncAddReaction | ( | final String | messageId, |
final String | reaction, | ||
final EMCallBack | callback | ||
) |
Adds a Reaction.
This is an asynchronous method.
messageId | The message ID. |
reaction | The message Reaction to add. |
callback | The result callback which contains the error information if the method fails. See EMCallBack. |
void com.hyphenate.chat.EMChatManager.asyncDeleteAllMsgsAndConversations | ( | boolean | clearSeverData, |
EMCallBack | deleteCallBack | ||
) |
Clears all conversations and all messages in them.
This is an asynchronous method.
clearSeverData | Whether to clear all conversations and all messages in them on the server.
|
false
:No. All local conversations and all messages in them will be cleared, while those on the server remain. deleteCallBack | The completion callback, which contains the description of the cause to the failure. |
void com.hyphenate.chat.EMChatManager.asyncFetchConversationsFromServer | ( | final EMValueCallBack< Map< String, EMConversation > > | callBack | ) |
Gets the conversation list from the server.
This is an asynchronous method.
void com.hyphenate.chat.EMChatManager.asyncFetchConversationsFromServer | ( | final int | limit, |
final String | cursor, | ||
final EMValueCallBack< EMCursorResult< EMConversation > > | callback | ||
) |
Gets the list of conversations from the server with pagination.
The SDK retrieves the list of conversations in the reverse chronological order of their active time (generally the timestamp of the last message).
If there is no message in the conversation, the SDK retrieves the list of conversations in the reverse chronological order of their creation time.
limit | The number of conversations that you expect to get on each page. The value range is [1,50]. |
cursor | The position from which to start to get data. If you pass in null or an empty string (""), the SDK retrieves conversations from the latest active one. |
callback | The query result EMCursorResult, including the cursor for getting data next time and the conversation list. For the last page, the return value of cursor is an empty string. |
void com.hyphenate.chat.EMChatManager.asyncFetchConversationsFromServer | ( | int | pageNum, |
int | pageSize, | ||
final EMValueCallBack< Map< String, EMConversation > > | callBack | ||
) |
Gets the conversation list from the server with pagination.
This is an asynchronous method.
pageNum | The current page number, starting from 1. |
pageSize | The number of conversations to get on each page. The value range is [1,20]. |
void com.hyphenate.chat.EMChatManager.asyncFetchGroupReadAcks | ( | final String | msgId, |
final int | pageSize, | ||
final String | startAckId, | ||
final EMValueCallBack< EMCursorResult< EMGroupReadAck > > | 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 ackGroupMessageRead(String, String, String).
This is an asynchronous method.
msgId | The message ID. |
pageSize | The number of read receipts for the group message that you expect to get on each page. The value range is [1,50]. |
startAckId | The 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. |
callBack | The result callback:
|
void com.hyphenate.chat.EMChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final EMConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final EMConversation.EMSearchDirection | direction, | ||
final EMValueCallBack< EMCursorResult< EMMessage > > | callBack | ||
) |
Uses the pagination to get the messages of all types in the conversation from the server according to the message search direction.
This is an asynchronous method.
conversationId | The conversation ID.
|
type | The conversation type. See EMConversationType. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as "null" or an empty string, the SDK retrieves messages according to the message search direction while ignoring this parameter.
|
direction | The message search direction. See EMConversation.EMSearchDirection.
|
callBack | The result callback:
|
void com.hyphenate.chat.EMChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final EMConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final EMValueCallBack< EMCursorResult< EMMessage > > | callBack | ||
) |
Uses the pagination to get the messages of all types in the conversation from the server.
This is an asynchronous method.
conversationId | The conversation ID.
|
type | The conversation type. See EMConversationType. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting 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 messages, starting from the latest one, in the reverse chronological order of when the server receives them. |
callBack | The result callback:
|
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.
conversationId | The conversation ID.
|
type | The conversation type. See EMConversationType. |
pageSize | The number of messages you expect to get on each page. The value range is [1,50]. |
cursor | The cursor position from which to start querying data. |
option | The parameter configuration class for querying historical messages. See EMFetchMessageOption. |
callBack | The result callback:
|
void com.hyphenate.chat.EMChatManager.asyncFetchPinnedConversationsFromServer | ( | final int | limit, |
final String | cursor, | ||
final EMValueCallBack< EMCursorResult< EMConversation > > | callback | ||
) |
Get the list of pinned conversations from the server with pagination.
The SDK returns pinned conversations in the reverse chronological order of their pinning.
limit | The number of conversations that you expect to get on each page. The value range is [1,50]. |
cursor | The position from which to start getting data. If you pass in null or an empty string (""), the SDK retrieves the pinned conversations from the latest pinned one. |
callback | The query result EMCursorResult, including the cursor for getting data next time and the list of pinned conversations. For the last page, the return value of cursor is an empty string. |
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.
filter | The filter. See EMCustomConversationFilter. If you want to get all conversations, pass in null. |
cleanConversationsCache | Whether to clear the cached conversations in memory:
|
callBack | The completion callback. If this call succeeds, calls EMValueCallBack#onSuccess(Object) and returns the list of filtered conversation. |
void com.hyphenate.chat.EMChatManager.asyncGetConversationsFromServerWithCursor | ( | @NonNull String | cursor, |
@NonNull EMConversationFilter | filter, | ||
EMValueCallBack< EMCursorResult< EMConversation > > | callback | ||
) |
Gets the conversations from the server with pagination according to the conversation filter class.
cursor | The position from which to start getting data. If you pass in an empty string, the SDK retrieves conversations from the latest marked one. |
filter | The conversation filter options: conversation mark and the number of conversations to retrieve on each page. |
callback | The completion callback, which contains the conversation list and the cursor for the next query. When the cursor is empty, all data is already retrieved. |
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.
conversationId | The conversation ID. |
callBack | The completion callback. If the call succeeds, the list of pined messages in the conversation are returned. If the call fails, the cause of the failure is returned. |
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.
messageId | The message ID. |
reaction | The Reaction content. |
cursor | The cursor position from which to start querying data. |
pageSize | The number of Reactions you expect to get on each page. |
callback | The query result EMCursorResult, which contains the cursor for the next query and EMMessageReaction list (only the first data entry is used). |
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.
messageIdList | The message ID. |
chatType | The conversation type. Only one-to-one chats (EMMessage.ChatType#Chat and group chats (EMMessage.ChatType#GroupChat) are allowed. |
groupId | The group ID, which is valid only for group chats. |
callback | 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. |
void com.hyphenate.chat.EMChatManager.asyncModifyMessage | ( | String | messageId, |
EMMessageBody | messageBodyModified, | ||
final EMValueCallBack< EMMessage > | callBack | ||
) |
Modifies a message.
After this method is called to modify a message, both the local message and the message on the server are modified.
This method can only modify a text message in one-to-one chats or group chats, but not in chat rooms.
Upon a message modification, the callback EMMessageListener#onMessageContentChanged(EMMessage, String, long) will be received by the message recipient(s) and in multi-device login scenarios.
messageId | The ID of the message to modify. |
messageBodyModified | The modified message body. |
callBack | The message modification callback. A object of the EMValueCallBack class. See EMValueCallBack,contains the message modified. |
void com.hyphenate.chat.EMChatManager.asyncPinConversation | ( | final String | conversationId, |
boolean | isPinned, | ||
final EMCallBack | callback | ||
) |
Sets whether to pin a conversation.
conversationId | The conversation ID. |
isPinned | Whether to pin the conversation:
|
false
: No. The conversation is unpinned. callback | The callback for setting whether to pin the conversation. |
void com.hyphenate.chat.EMChatManager.asyncPinMessage | ( | @NonNull String | messageId, |
EMCallBack | callBack | ||
) |
Pins a message.
This is an asynchronous method.
messageId | The ID of the message to be pinned. |
callBack | The completion callback, which contains the description of the cause to the failure. |
void com.hyphenate.chat.EMChatManager.asyncRecallMessage | ( | final EMMessage | message, |
final EMCallBack | callback | ||
) |
Recalls the sent message.
This is an asynchronous method.
message | The message object. |
callback | A object of the EMCallBack class. See EMCallBack. |
void com.hyphenate.chat.EMChatManager.asyncRecallMessage | ( | final EMMessage | message, |
String | ext, | ||
final EMCallBack | callback | ||
) |
Recalls the sent message.
This is an asynchronous method.
message | The message object. |
ext | The extended information. |
callback | A object of the EMCallBack class. See EMCallBack. |
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.
conversationIds | The list of conversation IDs. |
mark | The conversation mark to remove. |
callback | The completion callback, which contains the description of the cause to the failure. |
void com.hyphenate.chat.EMChatManager.asyncRemoveReaction | ( | final String | messageId, |
final String | reaction, | ||
final EMCallBack | callback | ||
) |
Deletes a Reaction.
This is an asynchronous method.
messageId | The message ID. |
reaction | The Reaction to delete. |
callback | The result callback which contains the error information if the method fails. See EMCallBack. |
void com.hyphenate.chat.EMChatManager.asyncReportMessage | ( | String | msgId, |
String | tag, | ||
String | reportReason, | ||
EMCallBack | callback | ||
) |
Reports an inappropriate message.
This is an asynchronous method.
msgId | The ID of the message to report. |
tag | The tag of the inappropriate message. You need to type a custom tag, like porn or ad . |
reportReason | The reporting reason. You need to type a specific reason. |
callback | The result callback. See EMCallBack.
|
void com.hyphenate.chat.EMChatManager.asyncUnPinMessage | ( | @NonNull String | messageId, |
EMCallBack | callBack | ||
) |
Unpins a message.
This is an asynchronous method.
messageId | The ID of the message to be unpinned. |
callBack | The completion callback, which contains the description of the cause to the failure. |
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.
boolean com.hyphenate.chat.EMChatManager.deleteConversation | ( | String | username, |
boolean | deleteMessages | ||
) |
Deletes a conversation and its local messages from the local database.
username | The conversation ID. |
deleteMessages | Whether to delete the historical messages with the conversation.
|
true
: Yes.false
: No. 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.
This is an asynchronous method.
username | The conversation ID. |
type | The conversation type. See EMConversationType. |
isDeleteServerMessages | Whether to delete the historical messages with the conversation.
|
deleteCallBack | The callback for the deletion of the conversation and its historical messages.
|
void com.hyphenate.chat.EMChatManager.deleteMessagesBeforeTimestamp | ( | long | timeStamp, |
EMCallBack | callback | ||
) |
Deletes local historical messages with a Unix timestamp before a specified one.
timeStamp | The starting Unix timestamp in the message for query. This unit is millisecond. |
callback | The result callback. See EMCallBack. |
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.
message | The combined message to download and parse. |
callback | The 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). |
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.
msg | The ID of the message with the attachment to be downloaded. |
void com.hyphenate.chat.EMChatManager.downloadThumbnail | ( | final EMMessage | msg | ) |
Downloads the message thumbnail.
msg | The message with the thumbnail to be downloaded. Only the image messages and video messages have a thumbnail. |
Map< String, EMConversation > com.hyphenate.chat.EMChatManager.fetchConversationsFromServer | ( | ) | throws HyphenateException |
Gets the conversation list from the server.
You can pull 10 conversations within 7 days by default (each conversation contains the latest historical message).
This is a synchronous method and blocks the current thread.
EMCursorResult< EMGroupReadAck > com.hyphenate.chat.EMChatManager.fetchGroupReadAcks | ( | String | msgId, |
int | pageSize, | ||
String | startAckId | ||
) | throws HyphenateException |
Uses the pagination to get read receipts for a group message from the server.
To send a read receipt for a group message, you can call ackGroupMessageRead(String, String, String).
This is a synchronous method and blocks the current thread.
msgId | The message ID. |
pageSize | The number of read receipts for the group message that you expect to get on each page. The value range is [1,50]. |
startAckId | The 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. |
HyphenateException | A description of the exception. See EMError. |
EMCursorResult< EMMessage > com.hyphenate.chat.EMChatManager.fetchHistoryMessages | ( | String | conversationId, |
EMConversationType | type, | ||
int | pageSize, | ||
String | startMsgId | ||
) | throws HyphenateException |
Uses the pagination to get the messages of all types in the conversation from the server.
This is a synchronous method and blocks the current thread.
conversationId | The conversation ID.
|
type | The conversation type. See EMConversationType. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, 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 messages, starting from the latest one, in the reverse chronological order of when the server receives them. |
HyphenateException | A description of the exception. See EMError. |
EMCursorResult< EMMessage > com.hyphenate.chat.EMChatManager.fetchHistoryMessages | ( | String | conversationId, |
EMConversationType | type, | ||
int | pageSize, | ||
String | startMsgId, | ||
EMConversation.EMSearchDirection | direction | ||
) | throws HyphenateException |
Uses the pagination to get the messages of all types in the conversation from the server according to the message search direction.
This is a synchronous method and blocks the current thread.
conversationId | The conversation ID.
|
type | The conversation type. See EMConversationType. |
pageSize | The number of messages you expect to get on each page. The value range is [1,50]. |
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as "null" or an empty string, the SDK retrieves messages according to the message search direction while ignoring this parameter.
|
direction | The message search direction. See EMConversation.EMSearchDirection.
|
HyphenateException | A description of the exception. See EMError. |
void com.hyphenate.chat.EMChatManager.fetchSupportLanguages | ( | EMValueCallBack< List< EMLanguage > > | callback | ) |
Gets all languages supported by the translation service.
callback | The result callback. See EMCallBack.
|
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.
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.
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.
id | The conversation ID. |
null
if the conversation is not found. 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.
id | The conversation ID:
|
type | The conversation type. See EMConversationType |
null
if the conversation is not found. 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.
username | The conversation ID:
|
type | The conversation type. See EMConversationType. |
createIfNotExists | Whether to create a conversation if the specified conversation is not found:
|
null
if the conversation is not found. 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.
username | The conversation ID.
|
type | The conversation type. See EMConversationType. |
createIfNotExists | Whether to create a conversation if the specified conversation is not found:
|
isChatThread | Whether to search for the chat thread conversation.
|
null
if the conversation is not found. List< EMConversation > com.hyphenate.chat.EMChatManager.getConversationsByType | ( | EMConversationType | type | ) |
Gets the list of conversations by conversation type.
type | The conversation type. See EMConversationType. |
EMMessage com.hyphenate.chat.EMChatManager.getMessage | ( | String | messageId | ) |
Gets the message by message ID.
messageId | The message ID. |
null
if the message does not exist. 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.
messageId | The message ID. |
reaction | The Reaction content. |
cursor | The cursor position from which to start querying data. |
pageSize | The number of Reactions you expect to get on each page. |
null
, all data is obtained. HyphenateException | A description of the exception, see EMError. |
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.
messageIdList | The message ID. |
chatType | The conversation type. Only the one-to-one chats (EMMessage.ChatType#Chat and group chats (EMMessage.ChatType#GroupChat) are allowed. |
groupId | The group ID, which is invalid only for group chats. |
UserList
of EMMessageReaction
indicates the summary data, which only contains the information of the first three users. HyphenateException | A description of the exception. See EMError. |
int com.hyphenate.chat.EMChatManager.getUnreadMessageCount | ( | ) |
Gets the unread message count.
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.
msgs | The messages to import. |
void com.hyphenate.chat.EMChatManager.loadAllConversations | ( | ) |
Loads all conversations from the local database into the memory.
Generally, this method is called upon successful login to speed up the loading of the conversation list.
boolean com.hyphenate.chat.EMChatManager.markAllConversationsAsRead | ( | ) |
Marks all conversations as read.
This method works only for the local conversations.
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.
message | The message instance. |
HyphenateException | A description of the exception. See EMError. |
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.
message | The message instance. |
ext | Extended Information |
HyphenateException | A description of the exception. See EMError. |
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.
listener | The conversation listener to remove. |
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.
listener | The message listener to remove. |
|
protected |
Unidirectionally removes historical message by message ID from the server.
conversationId | The conversation ID. |
type | The conversation type. |
msgIdList | The list of IDs of messages to be removed. |
callBack | The result callback which contains the error information if the method fails. See EMCallBack. |
|
protected |
Unidirectionally removes historical message by timestamp from the server.
conversationId | The conversation ID. |
type | The conversation type. |
beforeTimeStamp | The UNIX timestamp in millisecond. Messages with a timestamp smaller than the specified one will be removed. |
callBack | The result callback which contains the error information if the method fails. See EMCallBack. |
void com.hyphenate.chat.EMChatManager.removeReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws HyphenateException |
Deletes a Reaction.
This is a synchronous method.
messageId | The message ID. |
reaction | The Reaction content to delete. |
HyphenateException | A description of the exception. See EMError. |
void com.hyphenate.chat.EMChatManager.reportMessage | ( | String | msgId, |
String | tag, | ||
String | reportReason | ||
) | throws HyphenateException |
Reports an inappropriate message.
This is a synchronous method and blocks the current thread.
msgId | The ID of the inappropriate message. |
tag | The tag of the inappropriate message. You need to type a custom tag, like porn or ad . |
reportReason | The reporting reason. You need to type a specific reason. |
HyphenateException | A description of the exception. See EMError. |
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.
message | The message to store. |
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.
type | The message type. See Type. |
timeStamp | The 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. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The 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. |
direction | The message search direction. See EMConversation.EMSearchDirection.
|
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.
types | The message types. See Type. |
timeStamp | The 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. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The 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. |
direction | The message search direction. See EMConversation.EMSearchDirection.
|
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.
keywords | The keywords for query. |
timeStamp | The 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. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The 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. |
direction | The message search direction. See EMConversation.EMSearchDirection.
|
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.
keywords | The keywords for query. |
timeStamp | The 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. |
maxCount | The 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. |
from | The 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. |
direction | The message search direction. See EMConversation.EMSearchDirection.
|
searchScope | The message search scope. See EMConversation.EMMessageSearchScope. |
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).
msg | The message object to be sent. Make sure to set the param. |
void com.hyphenate.chat.EMChatManager.setVoiceMessageListened | ( | EMMessage | message | ) |
Marks a voice message as listened.
message | The message object. |
void com.hyphenate.chat.EMChatManager.translateMessage | ( | EMMessage | message, |
List< String > | languages, | ||
EMValueCallBack< EMMessage > | callback | ||
) |
Translates a text message.
message | The message object for translation. |
languages | The list of target language codes. |
callback | The result callback. See EMCallBack.
|
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.
message | The message object to update. |
boolean com.hyphenate.chat.EMChatManager.updateParticipant | ( | String | from, |
String | changeTo | ||
) |
Changes the data of one contact in the local database to those of the other contact.
Note
from | The user ID of the original contact. |
changeTo | The user ID of the new contact. |
true
: Success.false
: Failure.