EMChatManager class
~english The chat manager class, responsible for sending and receiving messages, loading and deleting conversations, and downloading attachments.
The sample code for sending a text message:
EMMessage msg = EMMessage.createTxtSendMessage(
username: toChatUsername, content: content);
await EMClient.getInstance.chatManager.sendMessage(msg);
~end
~chinese 聊天管理类,该类负责管理会话(加载,删除等)、发送消息、下载消息附件等。
比如,发送一条文本消息:
EMMessage msg = EMMessage.createTxtSendMessage(
targetId: toChatUsername, content: content);
await EMClient.getInstance.chatManager.sendMessage(msg);
~end
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addEventHandler(
String identifier, EMChatEventHandler handler) → void - ~english Adds the chat event handler. After calling this method, you can handle for chat event when they arrive.
-
addMessageEvent(
String identifier, ChatMessageEvent event) → void - ~english Adds a message status listener.
-
addReaction(
{required String messageId, required String reaction}) → Future< void> - ~english Adds a Reaction.
-
clearEventHandlers(
) → void - ~english Clear all chat event handlers. ~end
-
clearMessageEvent(
) → void - ~english Clears all message status listeners. ~end
-
deleteConversation(
String conversationId, {bool deleteMessages = true}) → Future< bool> - ~english Deletes a conversation and its related messages from the local database.
-
deleteMessagesBefore(
int timestamp) → Future< void> - ~english Deletes messages with timestamp that is before the specified one.
-
deleteRemoteConversation(
String conversationId, {EMConversationType conversationType = EMConversationType.Chat, bool isDeleteMessage = true}) → Future< void> - ~english Deletes the specified conversation and the related historical messages from the server.
-
deleteRemoteMessagesBefore(
{required String conversationId, required EMConversationType type, required int timestamp}) → Future< void> - ~english Unidirectionally removes historical message by timestamp from the server.
-
deleteRemoteMessagesWithIds(
{required String conversationId, required EMConversationType type, required List< String> msgIds}) → Future<void> - ~english Unidirectionally removes historical message by message ID from the server.
-
downloadAttachment(
EMMessage message) → Future< void> - ~english Downloads the attachment files from the server.
-
downloadThumbnail(
EMMessage message) → Future< void> - ~english Downloads the thumbnail if the message has not been downloaded before or if the download fails.
-
fetchCombineMessageDetail(
{required EMMessage message}) → Future< List< EMMessage> > - ~english Gets the details of a combined message.
-
fetchConversation(
{String? cursor, int pageSize = 20}) → Future< EMCursorResult< EMConversation> > - ~english Get the list of conversations from the server with pagination.
-
fetchConversationListFromServer(
{int pageNum = 1, int pageSize = 20}) → Future< List< EMConversation> > - ~english Gets the list of conversations from the server.
-
fetchGroupAcks(
String msgId, String groupId, {String? startAckId, int pageSize = 0}) → Future< EMCursorResult< EMGroupMessageAck> > - ~english Gets read receipts for group messages from the server with pagination.
-
fetchHistoryMessages(
{required String conversationId, EMConversationType type = EMConversationType.Chat, int pageSize = 20, EMSearchDirection direction = EMSearchDirection.Up, String startMsgId = ''}) → Future< EMCursorResult< EMMessage> > - ~english Gets historical messages of the conversation from the server with pagination.
-
fetchHistoryMessagesByOption(
String conversationId, EMConversationType type, {FetchMessageOptions? options, String? cursor, int pageSize = 50}) → Future< EMCursorResult< EMMessage> > - ~english Gets historical messages of a conversation from the server according to FetchMessageOptions.
-
fetchPinnedConversations(
{String? cursor, int pageSize = 20}) → Future< EMCursorResult< EMConversation> > - ~english Gets the list of pinned conversations from the server with pagination.
-
fetchReactionDetail(
{required String messageId, required String reaction, String? cursor, int pageSize = 20}) → Future< EMCursorResult< EMMessageReaction> > - ~english Gets the Reaction details.
-
fetchReactionList(
{required List< String> messageIds, required ChatType chatType, String? groupId}) → Future<Map< String, List< >EMMessageReaction> > - ~english Gets the list of Reactions.
-
fetchSupportedLanguages(
) → Future< List< EMTranslateLanguage> > - ~english Gets all languages supported by the translation service.
-
getConversation(
String conversationId, {EMConversationType type = EMConversationType.Chat, bool createIfNeed = true}) → Future< EMConversation?> - ~english Gets the conversation by conversation ID and conversation type.
-
getConversationsFromServer(
) → Future< List< EMConversation> > - ~english Gets the conversation list from the server.
-
getEventHandler(
String identifier) → EMChatEventHandler? - ~english Get the chat event handler.
-
getThreadConversation(
String threadId) → Future< EMConversation?> - ~english Gets the thread conversation by thread ID.
-
getUnreadMessageCount(
) → Future< int> - ~english Gets the count of the unread messages.
-
importMessages(
List< EMMessage> messages) → Future<void> - ~english Imports messages to the local database.
-
loadAllConversations(
) → Future< List< EMConversation> > - ~english Gets all conversations from the local database.
-
loadMessage(
String messageId) → Future< EMMessage?> - ~english Loads a message from the local database by message ID.
-
markAllConversationsAsRead(
) → Future< void> - ~english Marks all messages as read.
-
modifyMessage(
{required String messageId, required EMTextMessageBody msgBody}) → Future< EMMessage> - ~english Modifies a message.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pinConversation(
{required String conversationId, required bool isPinned}) → Future< void> - ~english Sets whether to pin a conversation.
-
recallMessage(
String messageId) → Future< void> - ~english Recalls the sent message.
-
removeEventHandler(
String identifier) → void - ~english Remove the chat event handler.
-
removeMessageEvent(
String identifier) → void - ~english Removes a message status listener.
-
removeReaction(
{required String messageId, required String reaction}) → Future< void> - ~english Deletes a Reaction.
-
reportMessage(
{required String messageId, required String tag, required String reason}) → Future< void> - ~english Reports an inappropriate message.
-
resendMessage(
EMMessage message) → Future< EMMessage> - ~english Resends a message.
-
searchMsgFromDB(
String keywords, {int timestamp = -1, int maxCount = 20, String from = '', EMSearchDirection direction = EMSearchDirection.Up}) → Future< List< EMMessage> > - ~english Retrieves messages from the database according to the parameters.
-
sendConversationReadAck(
String conversationId) → Future< void> - ~english Sends the conversation read receipt to the server. This method is only for one-to-one chat conversations.
-
sendGroupMessageReadAck(
String msgId, String groupId, {String? content}) → Future< void> - ~english Sends the group message receipt to the server.
-
sendMessage(
EMMessage message) → Future< EMMessage> - ~english Sends a message.
-
sendMessageReadAck(
EMMessage message) → Future< bool> - ~english Sends the read receipt to the server.
-
toString(
) → String -
A string representation of this object.
inherited
-
translateMessage(
{required EMMessage msg, required List< String> languages}) → Future<EMMessage> - ~english Translates a text message.
-
updateMessage(
EMMessage message) → Future< void> - ~english Updates the local message.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited