类 | |
| enum | AttachmentDownloadType |
Public 成员函数 | |
| 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< EMConversation > | getConversationsByType (EMConversationType type) |
| Map< String, EMConversation > | getAllConversations () |
| List< EMConversation > | getAllConversationsBySort () |
| 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< 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 | 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< 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 | 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 成员函数 | |
| void | removeMessagesFromServer (String conversationId, EMConversationType type, List< String > msgIdList, EMCallBack callBack) |
| void | removeMessagesFromServer (String conversationId, EMConversationType type, long beforeTimeStamp, EMCallBack callBack) |
聊天管理类,该类负责管理会话(加载,删除等)、发送消息、下载消息附件等。
发送文文本消息示例如下:
| void com.hyphenate.chat.EMChatManager.addConversationListener | ( | EMConversationListener | listener | ) |
注册会话监听器。
会话监听器可监听会话变化。
在不需要会话监听器时,可调用 removeConversationListener(EMConversationListener) 方法移除。
| listener | 要添加的会话监听,详见 EMConversationListener。 |
| void com.hyphenate.chat.EMChatManager.addMessageListener | ( | EMMessageListener | listener | ) |
注册消息监听器。
接收到新消息等回调可以通过设置此方法进行监听。
在不需要消息监听器时,可调用 removeMessageListener(EMMessageListener) 方法将其移除。
| listener | 要注册的消息监听,详见 EMMessageListener。 |
| void com.hyphenate.chat.EMChatManager.addReaction | ( | final String | messageId, |
| final String | reaction ) throws HyphenateException |
添加 Reaction。
同步方法。
| messageId | 消息 ID。 |
| reaction | 要添加的消息 Reaction。 |
| HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
| void com.hyphenate.chat.EMChatManager.asyncAddConversationMark | ( | @NonNull List< String > | conversationIds, |
| @NonNull EMMarkType | mark, | ||
| EMCallBack | callback ) |
标记会话。
调用该方法会同时为本地和服务器端的会话添加标记。
| conversationIds | 会话 ID 列表。 |
| mark | 要添加的会话标记。 |
| callback | 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncAddReaction | ( | final String | messageId, |
| final String | reaction, | ||
| final EMCallBack | callback ) |
添加 Reaction。
异步方法。
| messageId | 消息 ID。 |
| reaction | 要添加的消息 Reaction。 |
| callback | 处理结果回调,失败会返回失败原因。详见 EMCallBack。 |
| void com.hyphenate.chat.EMChatManager.asyncClearAllConversationUnreadMessageCount | ( | final EMCallBack | callBack | ) |
| void com.hyphenate.chat.EMChatManager.asyncClearConversationUnreadMessageCount | ( | final String | conversationId, |
| final EMCallBack | callBack ) |
清除指定会话的未读消息数。
本地未读数清零,同步给当前用户的其他设备。不发送已读回执给对方。
异步方法。
| conversationId | 会话 ID。 |
| callBack | 结果回调,详见 EMCallBack。 |
| void com.hyphenate.chat.EMChatManager.asyncDeleteAllMsgsAndConversations | ( | boolean | clearSeverData, |
| EMCallBack | deleteCallBack ) |
清空所有会话及其消息。
异步方法。
| clearSeverData | 是否删除服务端所有会话及其消息:
|
| deleteCallBack | 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncDeleteConversations | ( | List< String > | conversationIds, |
| boolean | deleteMessages, | ||
| EMCallBack | callBack ) |
批量删除本地会话。
异步方法。
| conversationIds | 要删除的会话 ID 列表。 |
| deleteMessages | 删除会话时是否同时删除本地的历史消息。
|
| callBack | 结果回调,成功时回调 EMCallBack#onSuccess(), 失败时回调 EMCallBack#onError(int, String)。 |
| void com.hyphenate.chat.EMChatManager.asyncFetchGroupMessageReadReceipts | ( | final String | msgId, |
| final int | pageSize, | ||
| final String | startAckId, | ||
| final EMValueCallBack< EMCursorResult< EMGroupReadReceipt > > | callBack ) |
从服务器分页获取群组消息已读回执详情。
发送群组消息回执,可调用 asyncSendMessageReadReceipts(List, EMCallBack)。
异步方法。
| msgId | 消息 ID。 |
| pageSize | 每页获取的群消息已读回执数。取值范围为 [1,50]。 |
| startAckId | 查询起始的已读回执 ID。该参数设置后,SDK 从指定的已读回执 ID 开始,按服务器接收已读回执的时间的逆序获取。 若该参数为空,SDK 从最新的已读回执开始按服务器接收回执时间的逆序获取。 |
| callBack | 结果回调。
|
| void com.hyphenate.chat.EMChatManager.asyncFetchHistoryMessages | ( | String | conversationId, |
| EMConversationType | type, | ||
| int | pageSize, | ||
| String | cursor, | ||
| EMFetchMessageOption | option, | ||
| final EMValueCallBack< EMCursorResult< EMMessage > > | callBack ) |
根据消息拉取参数配置类(EMFetchMessageOption)从服务器分页获取指定会话的历史消息。
异步方法。
| conversationId | 会话 ID。
|
| type | 会话类型, 详见 EMConversationType。 |
| pageSize | 每页期望获取的消息条数。取值范围为 [1,50]。 |
| cursor | 查询的起始游标位置。 |
| option | 查询历史消息的参数配置类,详见 EMFetchMessageOption。 |
| callBack | 结果回调:
|
| void com.hyphenate.chat.EMChatManager.asyncFilterConversationsFromDB | ( | EMCustomConversationFilter | filter, |
| boolean | cleanConversationsCache, | ||
| EMValueCallBack< List< EMConversation > > | callBack ) |
根据自定义会话过滤器获取本地所有会话。
调用该接口时,SDK 会根据过滤条件从本地数据库获取会话。
异步方法。
| filter | 过滤器,详见 EMCustomConversationFilter。若要获取全部会话,传入 null 即可。 |
| cleanConversationsCache | 是否清空内存缓存的会话。 |
| callBack | 结果回调,成功时回调 EMValueCallBack#onSuccess(Object),返回过滤后的会话列表。 |
| void com.hyphenate.chat.EMChatManager.asyncGetGroupMessageReadReceipts | ( | final List< EMMessage > | messages, |
| final EMValueCallBack< List< EMMessageReadReceipt > > | callBack ) |
从服务器批量获取消息的已读回执详情。
异步方法。
| messages | 消息列表,最多 20 条,必须属于同一会话。 |
| callBack | 结果回调。
|
| void com.hyphenate.chat.EMChatManager.asyncGetMessageCount | ( | EMValueCallBack< Integer > | callBack | ) |
获取本地数据库中消息总数
该方法为异步方法。
| callBack | 该方法完成调用的回调。如果该方法成功,会包含本地数据库中消息总数。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncGetPinnedMessagesFromServer | ( | @NonNull String | conversationId, |
| EMValueCallBack< List< EMMessage > > | callBack ) |
从服务端获取置顶消息。
该方法为异步方法。
| conversationId | 会话 ID。 |
| callBack | 该方法完成调用的回调。如果该方法成功,会包含所有置顶的消息。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncGetReactionDetail | ( | final String | messageId, |
| final String | reaction, | ||
| final String | cursor, | ||
| final int | pageSize, | ||
| final EMValueCallBack< EMCursorResult< EMMessageReaction > > | callback ) |
获取 Reaction 详细信息。
异步方法。
| messageId | 消息 ID。 |
| reaction | 消息 Reaction。 |
| cursor | 查询的起始游标位置。 |
| pageSize | 每页期望获取的 Reaction 数。 |
| callback | 处理结果回调,包含 cursor 和 EMMessageReaction 列表(仅使用该列表第一个数据即可)。 |
| void com.hyphenate.chat.EMChatManager.asyncGetReactionList | ( | final List< String > | messageIdList, |
| final EMMessage.ChatType | chatType, | ||
| final String | groupId, | ||
| final EMValueCallBack< Map< String, List< EMMessageReaction > > > | callback ) |
获取 Reaction 列表。
异步方法。
| messageIdList | 消息 ID。 |
| chatType | 会话类型,仅支持单聊(EMMessage.ChatType#Chat )和群聊(EMMessage.ChatType#GroupChat)。 |
| groupId | 群组 ID,该参数只对群聊生效。 |
| callback | 处理结果回调,包含消息 ID 对应的 Reaction 列表(EMMessageReaction 的用户列表 UserList 为概要数据,只包含前三个用户信息)。 |
| void com.hyphenate.chat.EMChatManager.asyncLoadConversationMessagesWithKeyword | ( | String | keyword, |
| long | timestamp, | ||
| String | sender, | ||
| EMConversation.EMSearchDirection | direction, | ||
| EMConversation.EMMessageSearchScope | scope, | ||
| EMValueCallBack< Map< String, List< String > > > | callBack ) |
通过关键词从本地数据库中获取消息,返回会话 ID 及消息 ID 列表的映射关系。消息ID列表按 direction 设置的方向排列。
| keyword | 搜索关键词,设为 null 表示忽略该参数。 |
| timestamp | 搜索开始的 Unix 时间戳。单位为毫秒。如果该参数设置的时间戳为负数,则从最新消息向前获取。 |
| sender | 消息发送方。设为 null 表示忽略该参数。 |
| direction | 消息搜索方向。详见 EMConversation.EMSearchDirection。
|
| scope | 消息搜索范围。详见 EMConversation.EMMessageSearchScope。 |
| callBack | 该方法完成调用的回调。 如果该方法调用成功,回调 EMValueCallBack#onSuccess(Map<String,List<String>>)返回会话ID及消息ID列表的映射关系。 其中key为会话ID,value为消息ID列表。消息ID列表按direction设置的方向排列。 如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncLoadMessages | ( | @NonNull List< String > | messageIds, |
| @NonNull String | conversationId, | ||
| final EMValueCallBack< List< EMMessage > > | callback ) |
从 SDK 本地数据库获取指定 ID 的消息,一次最多获取20条消息,返回的消息按照时间倒序排列。
| messageIds | 消息 ID 列表。列表长度取值范围 [0,20]。该参数不能为 null。 |
| conversationId | 会话 ID。该参数不能为 null和空字符串。 |
| callback | 该方法完成调用的回调。 如果该方法调用成功,返回的 List 中包含指定ID的消息对象。 如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncModifyMessage | ( | String | messageId, |
| @Nullable EMMessageBody | messageBodyModified, | ||
| @Nullable Map< String, Object > | ext, | ||
| final EMValueCallBack< EMMessage > | callBack ) |
修改本地以及服务端消息。
ext。ext。该方法会同时更新服务器和本地的消息,消息 ID 不会更新。
多设备和该消息的接收方可通过 EMMessageListener#onMessageContentChanged(EMMessage, String, long) 回调监听消息是否有变更。
| messageId | 消息 ID。 |
| messageBodyModified | 内容修改后的消息体。只有文本消息和自定义消息支持。传 null 表示不修改。 |
| ext | 修改后的消息扩展,Map类型,泛型为<String,Object>,其中Object支持的类型有:{String.class, Integer.class, Double.class,Boolean.class,Long.class,Float.class,JSONObject.class, JSONArray.class}。 将会覆盖之前的扩展信息,传 null 表示不修改。 |
| callBack | 消息修改是否成功的回调。EMValueCallBack 类的对象,详见 EMValueCallBack,包含已修改的消息对象。 |
| void com.hyphenate.chat.EMChatManager.asyncPinConversation | ( | final String | conversationId, |
| boolean | isPinned, | ||
| final EMCallBack | callback ) |
设置是否置顶会话。
| conversationId | 会话 ID。 |
| isPinned | 是否置顶会话:
|
| callback | 设置会话置顶状态的结果回调。 |
| void com.hyphenate.chat.EMChatManager.asyncPinMessage | ( | @NonNull String | messageId, |
| EMCallBack | callBack ) |
置顶消息。
该方法为异步方法。
| messageId | 消息 ID。 |
| callBack | 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncRecallMessage | ( | final EMMessage | message, |
| final EMCallBack | callback ) |
| void com.hyphenate.chat.EMChatManager.asyncRecallMessage | ( | final EMMessage | message, |
| String | ext, | ||
| final EMCallBack | callback ) |
| void com.hyphenate.chat.EMChatManager.asyncRemoveConversationMark | ( | @NonNull List< String > | conversationIds, |
| @NonNull EMMarkType | mark, | ||
| EMCallBack | callback ) |
取消标记会话。
调用该方法会同时为本地和服务器端的会话添加标记。
| conversationIds | 会话 ID 列表。 |
| mark | 要移除的会话标记。 |
| callback | 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.asyncRemoveReaction | ( | final String | messageId, |
| final String | reaction, | ||
| final EMCallBack | callback ) |
| void com.hyphenate.chat.EMChatManager.asyncSearchMessagesFromServer | ( | @NonNull final EMMessageSearchOption | option, |
| final int | pageSize, | ||
| final int | pageNum, | ||
| final EMValueCallBack< EMPageResult< EMSearchServerMessageResult > > | callBack ) |
从服务端搜索消息。 该功能需要在 Console 开通「消息搜索」增值服务。
| option | 搜索参数配置,详见 EMMessageSearchOption。 |
| pageSize | 每页返回条数,取值范围为 [1,100]。 |
| pageNum | 分页页码,从 1 开始。 |
| callBack | 该方法完成调用的回调,返回搜索结果或错误信息,搜索结果按照相关性排序。 |
| void com.hyphenate.chat.EMChatManager.asyncSendMessageReadReceipts | ( | final List< EMMessage > | messages, |
| final EMCallBack | callBack ) |
批量发送消息已读回执。
单聊和群聊统一使用该方法。所有消息必须属于同一个会话。 该方法不会改变会话未读数。 消息的 EMMessage#isNeedReadReceipt() 需为 true。
异步方法。
| messages | 消息列表,最多 50 条。无需回执或已回执的消息会被跳过,没有待回执消息时不做任何操作。 |
| callBack | 结果回调。
|
| void com.hyphenate.chat.EMChatManager.asyncUnPinMessage | ( | @NonNull String | messageId, |
| EMCallBack | callBack ) |
取消置顶消息。
该方法为异步方法。
| messageId | 消息 ID。 |
| callBack | 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。 |
| void com.hyphenate.chat.EMChatManager.cleanConversationsMemoryCache | ( | ) |
清除本地内存中的所有会话释放内存。
注意:释放内存后,通过 getAllConversations()、getAllConversationsBySort() 从内存里获取到的会话数可能为 0。通过getUnreadMessageCount()获取到的未读消息数可能为 0。
若需要获取所有会话和未读数,需要先调用 loadAllConversations()或者 asyncFilterConversationsFromDB(EMCustomConversationFilter, boolean, EMValueCallBack) 从数据库重新加载会话到内存里。
| boolean com.hyphenate.chat.EMChatManager.deleteConversation | ( | String | conversationId, |
| boolean | deleteMessages ) |
删除指定会话及其本地历史消息。
| conversationId | 会话 ID。 |
| deleteMessages | 删除会话时是否同时删除本地的历史消息。
|
true:是;false: 否。 | void com.hyphenate.chat.EMChatManager.deleteConversationFromServer | ( | String | username, |
| EMConversationType | type, | ||
| boolean | isDeleteServerMessages, | ||
| EMCallBack | deleteCallBack ) |
删除服务端和本地的指定会话及其历史消息。
异步方法。
| username | 会话 ID。 |
| type | 会话类型,详见 EMConversationType。 |
| isDeleteServerMessages | 删除会话时是否同时删除历史消息。
|
| deleteCallBack | 删除服务端会话及其历史消息成功与否的回调。
|
| void com.hyphenate.chat.EMChatManager.deleteMessagesBeforeTimestamp | ( | long | timeStamp, |
| EMCallBack | callback ) |
删除指定时间戳之前的本地历史消息。
| timeStamp | 查询的消息的起始 Unix 时间戳,单位为毫秒。 |
| callback | 删除结果回调,详见 EMCallBack。 |
| void com.hyphenate.chat.EMChatManager.downloadAndParseCombineMessage | ( | EMMessage | message, |
| EMValueCallBack< List< EMMessage > > | callback ) |
下载并解析合并消息的附件。
对于一条合并消息,首次调用该方法会下载和解析合并消息附件,然后返回消息列表,而后续调用会存在以下情况:
| message | 要下载和解析的合并消息。 |
| callback | 结果回调,成功时回调 EMValueCallBack#onSuccess(Object),返回解析成功的消息列表; 失败时回调 EMValueCallBack#onError(int, String)。 |
| void com.hyphenate.chat.EMChatManager.downloadAttachment | ( | final EMMessage | msg | ) |
下载消息的附件。
若附件自动下载失败,也可以调用此方法下载。
| msg | 要下载附件的消息。 |
downloadAttachment(EMMessage, EMCallBack) 代替。| void com.hyphenate.chat.EMChatManager.downloadAttachment | ( | final EMMessage | msg, |
| @Nullable final EMCallBack | callback ) |
下载消息的附件。
| msg | 要下载附件的消息。 |
| callback | 下载状态回调。若传入非空,会通过 EMCallBack#onProgress(int, String)、 EMCallBack#onSuccess() 和 EMCallBack#onError(int, String) 返回结果。 |
| void com.hyphenate.chat.EMChatManager.downloadBigImage | ( | final EMMessage | msg, |
| @Nullable final EMCallBack | callback ) |
下载图片消息的大图。
该方法仅适用于图片消息。
| msg | 要下载大图的图片消息。 |
| callback | 下载状态回调。若传入非空,会通过 EMCallBack#onProgress(int, String)、 EMCallBack#onSuccess() 和 EMCallBack#onError(int, String) 返回结果。 |
| void com.hyphenate.chat.EMChatManager.downloadThumbnail | ( | final EMMessage | msg | ) |
| void com.hyphenate.chat.EMChatManager.downloadThumbnail | ( | final EMMessage | msg, |
| @Nullable final EMCallBack | callback ) |
下载消息的缩略图。
该方法仅适用于图片消息和视频消息。
| msg | 要下载缩略图的消息。 |
| callback | 下载状态回调。若传入非空,会通过 EMCallBack#onProgress(int, String)、 EMCallBack#onSuccess() 和 EMCallBack#onError(int, String) 返回结果。 |
| void com.hyphenate.chat.EMChatManager.fetchSupportLanguages | ( | EMValueCallBack< List< EMLanguage > > | callback | ) |
获取翻译服务支持的语言。
| callback | 结果回调,详见 EMCallBack。
|
| Map< String, EMConversation > com.hyphenate.chat.EMChatManager.getAllConversations | ( | ) |
获取本地当前所有会话。
该方法会先从内存中获取,如果未找到任何会话,从本地数据库获取。
| List< EMConversation > com.hyphenate.chat.EMChatManager.getAllConversationsBySort | ( | ) |
获取本地当前所有会话。
SDK 按照最近一条消息的时间戳的倒序返回会话,置顶会话在前,非置顶会话在后。
该方法会先从内存中获取,如果未找到任何会话,SDK 从本地数据库获取。
| EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | id | ) |
获取指定 ID 的会话对象。
| id | 会话 ID。 |
| EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | id, |
| EMConversationType | type ) |
根据会话 ID 以及会话类型获取会话。
没有找到返回空值。
| id | 会话 ID。
|
| type | 会话类型,详见 EMConversationType。 |
| EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | username, |
| EMConversationType | type, | ||
| boolean | createIfNotExists ) |
根据会话 ID 和会话类型获取会话。
| username | 会话 ID。
|
| type | 会话类型,详见 EMConversationType。 |
| createIfNotExists | 未找到指定会话时是否创建一个新会话。
|
| EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | username, |
| EMConversationType | type, | ||
| boolean | createIfNotExists, | ||
| boolean | isChatThread ) |
根据会话 ID 以及会话类型获取会话。
| username | 会话 ID。
|
| type | 会话类型,详见 EMConversationType。 |
| createIfNotExists | 未找到指定会话时是否创建一个新会话。
|
| isChatThread | 是否查找子区会话。
|
| List< EMConversation > com.hyphenate.chat.EMChatManager.getConversationsByType | ( | EMConversationType | type | ) |
| EMMessage com.hyphenate.chat.EMChatManager.getMessage | ( | String | messageId | ) |
获取指定 ID 的消息对象。
| messageId | 消息 ID。 |
| EMCursorResult< EMMessageReaction > com.hyphenate.chat.EMChatManager.getReactionDetail | ( | final String | messageId, |
| final String | reaction, | ||
| final String | cursor, | ||
| final int | pageSize ) throws HyphenateException |
获取 Reaction 详细信息。
同步方法。
| messageId | 消息 ID。 |
| reaction | 消息 Reaction 内容。 |
| cursor | 查询的起始游标位置。 |
| pageSize | 每页期望获取的 Reaction 数。 |
EMCursorResult,包含 cursor 和 Reaction 列表。若 cursor 为空表示数据已全部获取。 | Map< String, List< EMMessageReaction > > com.hyphenate.chat.EMChatManager.getReactionList | ( | final List< String > | messageIdList, |
| final EMMessage.ChatType | chatType, | ||
| final String | groupId ) throws HyphenateException |
获取 Reaction 列表。
同步方法。
| messageIdList | 消息 ID。 |
| chatType | 会话类型,仅支持单聊(EMMessage.ChatType#Chat)和群聊(EMMessage.ChatType#GroupChat)。 |
| groupId | 群组 ID,该参数仅对群聊生效。 |
EMMessageReaction 的用户列表 UserList 为概要数据,只包含前三个用户信息)。 | int com.hyphenate.chat.EMChatManager.getUnreadMessageCount | ( | ) |
| synchronized void com.hyphenate.chat.EMChatManager.importMessages | ( | List< EMMessage > | msgs | ) |
将消息导入本地数据库。
你只能将你发送或接收的消息导入本地数据库。
推荐一次导入 1,000 条以内的数据。
| msgs | 需要导入数据库的消息。 |
| void com.hyphenate.chat.EMChatManager.recallMessage | ( | EMMessage | message | ) | throws HyphenateException |
撤回发送成功的消息。
若消息发送和撤回时接收方为离线状态,接收方会收到消息撤回回调 EMMessageListener#onMessageRecalled,不会收到该消息。
同步方法,会阻塞当前线程。
| message | 消息对象。 |
| HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
| void com.hyphenate.chat.EMChatManager.recallMessage | ( | EMMessage | message, |
| String | ext ) throws HyphenateException |
撤回发送成功的消息。
若消息发送和撤回时接收方为离线状态,接收方会收到消息撤回回调 EMMessageListener#onMessageRecalled,不会收到该消息。
同步方法,会阻塞当前线程。
| message | 消息对象。 |
| ext | 扩展信息 |
| HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
| void com.hyphenate.chat.EMChatManager.removeConversationListener | ( | EMConversationListener | listener | ) |
移除会话监听器。
调用 addConversationListener(EMConversationListener) 添加会话监听器后再调用本方法移除。
| listener | 要移除的会话监听器,详见 EMConversationListener。 |
| void com.hyphenate.chat.EMChatManager.removeMessageListener | ( | EMMessageListener | listener | ) |
移除消息监听器。
调用 addMessageListener(EMMessageListener) 添加消息监听后再调用本方法移除。
| listener | 要移除的监听器,详见 EMMessageListener。 |
|
protected |
根据消息 ID 单向删除漫游消息。
| conversationId | 会话 ID。 |
| type | 会话类型。 |
| msgIdList | 要删除的消息 ID 列表。 |
| callBack | 处理结果回调,详见 EMCallBack。 |
|
protected |
根据时间戳单向删除漫游消息。
| conversationId | 会话 ID。 |
| type | 会话类型。 |
| beforeTimeStamp | UNIX 时间戳,单位为毫秒。若消息的 UNIX 时间戳小于设置的值,则会被删除。 |
| callBack | 处理结果回调,详见 EMCallBack。 |
| void com.hyphenate.chat.EMChatManager.removeReaction | ( | final String | messageId, |
| final String | reaction ) throws HyphenateException |
删除 Reaction。
同步方法。
| messageId | 消息 ID。 |
| reaction | 要删除的 Reaction。 |
| HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
| void com.hyphenate.chat.EMChatManager.saveMessage | ( | EMMessage | message | ) |
| List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB | ( | @NonNull Type | type, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMConversation.EMSearchDirection | direction ) |
从本地数据库获取一定数量的特定类型的消息。
| type | 消息类型。详见 Type。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,搜索消息时对发送方不限制。 |
| direction | 消息搜索方向。详见 EMConversation.EMSearchDirection。
|
| List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB | ( | Set< Type > | types, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMConversation.EMSearchDirection | direction ) |
从本地数据库获取一定数量的多种类型的消息。
| types | 消息类型。详见 Type。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,搜索消息时对发送方不限制。 |
| direction | 消息搜索方向。详见 EMConversation.EMSearchDirection。
|
| List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMConversation.EMSearchDirection | direction ) |
从本地数据库获取包含特定关键字的消息。
| keywords | 查询关键字。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,搜索消息时对发送方不限制。 |
| direction | 消息搜索方向。详见 EMConversation.EMSearchDirection。
|
| List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMConversation.EMSearchDirection | direction, | ||
| EMConversation.EMMessageSearchScope | searchScope ) |
从本地数据库获取包含特定关键字的消息。
| keywords | 查询关键字。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。如果设为小于等于 0,SDK 会获取一条消息。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,搜索消息时对发送方不限制。 |
| direction | 消息搜索方向。详见 EMConversation.EMSearchDirection。
|
| searchScope | 消息搜索范围。详见 EMConversation.EMMessageSearchScope。 |
| void com.hyphenate.chat.EMChatManager.sendMessage | ( | final EMMessage | msg | ) |
发送消息。
如果是语音,图片类等有附件的消息,SDK 会自动上传附件。
可以通过 EMOptions#setAutoTransferMessageAttachments(boolean) 设置是否上传到聊天服务器。
发送消息的状态,可以通过设置 EMMessage#setMessageStatusCallback(EMCallBack) 进行监听。
| msg | 要发送的消息,必填。 |
| void com.hyphenate.chat.EMChatManager.setVoiceMessageListened | ( | EMMessage | message | ) |
将语音消息设置为已听。
| message | 要设置的消息对象。 |
| void com.hyphenate.chat.EMChatManager.translateMessage | ( | EMMessage | message, |
| List< String > | languages, | ||
| EMValueCallBack< EMMessage > | callback ) |
翻译一条文本消息。
| message | 要翻译的消息对象。 |
| languages | 目标语言代码列表。 |
| callback | 结果回调,详见 EMCallBack。
|
| boolean com.hyphenate.chat.EMChatManager.updateMessage | ( | EMMessage | message | ) |
更新本地消息。
该方法会同时更新本地内存和数据库中的消息。
| message | 要更新的消息对象。 |
| void com.hyphenate.chat.EMChatManager.voiceFileToText | ( | final String | filePath, |
| final EMAudioParams | audioParams, | ||
| final EMValueCallBack< String > | callback ) |
将本地语音文件转换为文本。
目前支持 EMAudioParams.AudioFormat#PCM、EMAudioParams.AudioFormat#MP3 和 EMAudioParams.AudioFormat#AMR 格式。
| filePath | 本地语音文件路径。 |
| audioParams | 语音参数。
|
| callback | 结果回调。成功时返回转换的文本,失败时返回错误码和描述。 |
| void com.hyphenate.chat.EMChatManager.voiceMessageToText | ( | final EMMessage | message, |
| final EMValueCallBack< String > | callback ) |
将语音消息转换为文本。
仅支持发送成功的语音消息。
转换成功后,结果将返回给回调函数,同时你也可以通过 EMVoiceMessageBody#getText() 获取该文本。
支持 AMR 和 MP3 格式的语音消息,不支持 PCM 格式的直接转换。
| message | 语音消息对象。 |
| callback | 结果回调。成功则返回转换的文本;失败则返回错误码及描述。 |