更新时间: 2020-08-26
# 获取所有会话未读数
获取所有会话类型(除聊天室外)的未读数
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
callback | ResultCallback<Integer> | 是 | 回调接口 |
# 代码示例
RongIMClient.getInstance().getTotalUnreadCount(new ResultCallback<Integer>() { /** * 成功回调 * @param unReadCount 未读数 */ @Override public void onSuccess(Integer unReadCount) { } /** * 错误回调 * @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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 获取指定会话未读数
获取指定会话(除聊天室外)的未读数
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversationType | ConversationType (opens new window) | 是 | 会话类型. 当前为 ConversattionType.PRIVATE |
targetId | String | 是 | 接收方的 userId |
callback | ResultCallback<Integer> | 是 | 回调接口 |
# 代码示例
ConversattionType conversationType = ConversattionType.PRIVATE; String targetId = "接收方的 userId"; RongIMClient.getInstance().getUnreadCount(conversationType, targetId, new ResultCallback<Integer>() { /** * 成功回调 * @param unReadCount 未读数 */ @Override public void onSuccess(Integer unReadCount) { } /** * 错误回调 * @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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 按会话类型获取未读数
获取多个指定会话类型(除聊天室外)的未读数
# 参数说明
参数 | 类型 | 必填 | 说明 | 最低版本 |
---|---|---|---|---|
conversationType | ConversationType (opens new window)[] | 是 | 会话类型数组 | 2.9.15 |
containBlocked | boolean | 是 | 是否包含消息免打扰的未读消息数, true 为携带, false 为不携带 | 2.9.15 |
callback | ResultCallback<Integer> | 是 | 回调接口 | 2.9.15 |
# 代码示例
ConversationTypes[] conversationTypes = {ConversationTypes.PRIVATE, ConversationTypes.GROUP}; boolean containBlocked = true; RongIMClient.getInstance().getUnreadCount(conversationTypes, containBlocked, new ResultCallback<Integer>() { /** * 成功回调 * @param unReadCount 未读数 */ @Override public void onSuccess(Integer unReadCount) { } /** * 错误回调 * @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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 清除指定会话未读数
清除指定会话(除聊天室外)的未读书
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
conversationType | ConversationType (opens new window) | 是 | 会话类型. 当前为 ConversattionType.PRIVATE |
targetId | String | 是 | 接收方的 userId |
timestamp | long | 是 | 时间戳, 此时间戳之前的未读消息都会清理 |
callback | OperationCallback | 否 | 回调接口 |
# 代码示例
ConversattionType conversationType = ConversattionType.PRIVATE; String targetId = "接收方的 userId"; long timestamp = 1585811571; RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId, timestamp, new OperationCallback() { /** * 成功回调 * @param unReadCount 未读数 */ @Override public void onSuccess() { } /** * 错误回调 * @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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24