File tree Expand file tree Collapse file tree 6 files changed +41
-10
lines changed Expand file tree Collapse file tree 6 files changed +41
-10
lines changed Original file line number Diff line number Diff line change 1818- ` EMChatManager.getConversation ` :读取本地指定会话的消息。
1919- ` EMChatManager.loadMessage ` :根据消息 ID 获取消息。
2020- ` EMConversation.loadMessagesWithMsgType ` :获取本地存储的指定会话中特定类型的消息。
21- - ` EMConversation.loadMessagesFromTime ` :获取一定时间段内本地指定会话中发送和接收的消息
21+ - ` EMConversation.loadMessagesFromTime ` :获取一定时间段内本地指定会话中发送和接收的消息。
22+ - ` EMChatManager.loadConversationMessagesWithKeyword ` :根据关键字获取指定会话中的消息。
2223
2324## 前提条件
2425
@@ -209,4 +210,21 @@ if (conversation != null) {
209210 endTime: endMs,
210211 );
211212}
212- ```
213+ ```
214+
215+ ### 根据关键字获取会话中的消息
216+
217+ 自 SDK 4.15.2 开始,你可以通过设置关键字获取单个会话中的某些消息。SDK 返回会话 ID 及消息 ID 列表的 Map,消息 ID 根据你设置的 ` direction ` 参数按照消息时间戳的正序或倒序列出。
218+
219+ ``` dart
220+ Map<String, List<String>> result =
221+ await EMClient.getInstance.chatManager.loadConversationMessagesWithKeyword(
222+ keyword: "hello", // 搜索包含 "hello" 的消息
223+ timestamp: -1,
224+ sender: null,
225+ direction: EMSearchDirection.Up,
226+ scope: MessageSearchScope.All,
227+ );
228+ ```
229+
230+ 调用上述 API 获取到会话 ID 和对应的消息列表后,如果需要使用获取的会话 ID 调用` EMChatManager#getConversation ` 进一步操作,则需将 ` createIfNeed ` 参数设置为 ` false ` (默认为 ` true ` )。 原因是上述 API 获取到的会话 ID 从消息中得到的,因此并不能证明该会话是存在的 (有可能已被删除)。所以,你在调用 ` EMChatManager#getConversation ` 时传入了获取的会话 ID,则需将 ` createIfNeed ` 参数设置为 ` false ` (默认为 ` true ` ),同时还需对 ` getConversation ` 进行是否为空的判断,避免创建会话错误。例如: 调用 ` loadConversationMessagesWithKeyword ` 获取了群组会话 ID(即群组 ID)且该会话已删除,将该群组 ID 传入了 ` EMChatManager#getConversation ` ,该 API 中的 ` createIfNeed ` 设置为 ` true ` ,` type ` 设置为 ` Chat ` ,则 SDK 会创建单聊会话。
Original file line number Diff line number Diff line change 22
33<Toc />
44
5+ ## 版本 v4.15.1 2025-11-7
6+
7+ #### 新增特性
8+
9+ - 新增 ` getCurrentDeviceId ` 方法获取你当前设备的设备 ID。
10+ - 支持 [ 根据关键字获取单个会话中的消息] ( message_retrieve.html#根据关键字获取会话中的消息 ) 。
11+
12+ #### 修复
13+
14+ - 修复被登出时,返回 220 的错误码无法触发回调的问题。
15+ - 修复 ` fetchReactionDetail ` 获取不存在的 Reaction 时崩溃的问题。
16+ - 修复 Android 上频繁调用 ` EMConversation ` 中的 API 时, 导致的 ANR 问题。
17+
518## 版本 v4.15.1 2025-8-19
619
720- 修复 ` updatePushNickname ` 在未登录和参数异常时导致的崩溃问题。
Original file line number Diff line number Diff line change 66
77你可以查看 UIKit 源码和 Android Demo 源码:
88
9- - UIKit 源码:点击 [ GitHub] ( https://github.com/easemob/easemob-uikit-android ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-android ) 地址访问 。
10- - Android Demo:点击 [ GitHub] ( https://github.com/easemob/easemob-demo-android ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-android ) 地址访问 。
9+ - UIKit 源码:可查看 [ GitHub] ( https://github.com/easemob/easemob-uikit-android ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-android ) 源码地址 。
10+ - Android Demo:可查看 [ GitHub] ( https://github.com/easemob/easemob-demo-android ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-android ) 源码地址 。
1111
1212## UIKit 基本项目结构
1313
Original file line number Diff line number Diff line change 66
77你可以查看 UIKit 源码和 Flutter Demo 源码:
88
9- - UIKit 源码:点击 [ GitHub] ( https://github.com/easemob/easemob-uikit-flutter ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-flutter ) 地址访问 。
10- - Flutter Demo:点击 [ GitHub] ( https://github.com/easemob/easemob-demo-flutter ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-flutter ) 地址访问 。
9+ - UIKit 源码:可查看 [ GitHub] ( https://github.com/easemob/easemob-uikit-flutter ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-flutter ) 源码地址 。
10+ - Flutter Demo:可查看 [ GitHub] ( https://github.com/easemob/easemob-demo-flutter ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-flutter ) 源码地址 。
1111
1212## UIKit 基本项目结构
1313
Original file line number Diff line number Diff line change 66
77你可以查看 UIKit 源码和 iOS Demo 源码:
88
9- - UIKit 源码:点击 [ GitHub] ( https://github.com/easemob/easemob-uikit-ios ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-ios ) 地址访问 。
10- - iOS Demo:点击 [ GitHub] ( https://github.com/easemob/easemob-demo-ios ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-ios ) 地址访问 。
9+ - UIKit 源码:可查看 [ GitHub] ( https://github.com/easemob/easemob-uikit-ios ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-ios ) 源码地址 。
10+ - iOS Demo:可查看 [ GitHub] ( https://github.com/easemob/easemob-demo-ios ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-ios ) 源码地址 。
1111
1212## 项目结构
1313
Original file line number Diff line number Diff line change 66
77你可以查看 UIKit 源码和 Web Demo 源码:
88
9- - UIKit 源码:点击 [ GitHub] ( https://github.com/easemob/easemob-uikit-react/tree/main ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-react/tree/main ) 地址访问 。
10- - Web React Demo:点击 [ GitHub] ( https://github.com/easemob/easemob-demo-react/tree/dev_4.0 ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-react ) 地址访问 。
9+ - UIKit 源码:可查看 [ GitHub] ( https://github.com/easemob/easemob-uikit-react/tree/main ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-uikit-react/tree/main ) 源码地址 。
10+ - Web React Demo:可查看 [ GitHub] ( https://github.com/easemob/easemob-demo-react/tree/dev_4.0 ) 或 [ Gitee] ( https://gitee.com/easemob-code/easemob-demo-react ) 源码地址 。
1111
1212## 技术原理
1313
You can’t perform that action at this time.
0 commit comments