更新时间: 2020-08-26
# 通过关键字搜索
通过关键字搜索指定用户的本地历史消息记录
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversationType | ConversationType (opens new window) | 是 | 会话类型. 当前为 ConversationType.PRIVATE. |
targetId | String | 是 | 接收方的 userId |
keyword | String | 是 | 搜索的关键字 |
count | int | 是 | 每页的数量. 1. 传0时, 会返回所有搜索到的消息. 2. 非0时, 则按照每页数量返回. 3. 每页数量最多 20 条 |
beginTime | long | 是 | 查询记录的起始时间. 1. 传0时, 从最新消息开始搜索. 2. 非 0 时, 从该时间往前搜索 |
callback | IRongCallback.ResultCallback<List<Message>> | 是 | 消息的回调 |
# 代码示例
ConversationType conversationType = ConversationType.PRIVATE; String targetId = "{TARGETT_ID}"; String keyword = "你好"; int count = 20; long beginTime = "122323344"; RongIMClient.getInstance().searchMessages(conversationType, targetId, keyword, count, beginTime, new RongIMClient.ResultCallback<Message>() { /** * 成功回调 * @param messages 查找匹配到的消息集合 */ @Override public void onSuccess(List<Messag> messages) { } /** * 失败回调 * @param errorCode 错误码 */ @Override public void onError(RongIMClient.ErrorCode errorCode) { } });
已复制
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 通过用户 ID 搜索
分页搜索指定会话聊天记录
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversationType | ConversationType (opens new window) | 是 | 会话类型. 当前为 ConversationType.PRIVATE. |
targetId | String | 是 | 接收方的 userId |
userId | String | 是 | 要查询的用户 ID |
count | int | 是 | 搜索结果数量. 最大返回数量为 100 |
beginTime | long | 是 | 查询记录的起始时间. 1. 传0时从最新消息开始搜索. 2. 非 0 时, 从该时间往前搜索 |
callback | IRongCallback.ResultCallback<List<Message>> | 是 | 消息的回调 |
# 代码示例
ConversationType conversationType = ConversationType.PRIVATE; String targetId = "{TARGETT_ID}"; String userId = "查询的用户 ID"; int count = 20; long beginTime = "1585815113"; RongIMClient.getInstance().searchMessagesByUser(conversationType, targetId, userId, count, beginTime, new RongIMClient.ResultCallback<Message>() { /** * 成功回调 * @param messages 查找匹配到的消息集合 */ @Override public void onSuccess(List<Messag> messages) { } /** * 失败回调 * @param errorCode 错误码 */ @Override public void onError(RongIMClient.ErrorCode errorCode) { } });
已复制
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25