V2TimValueCallback<V2TimMsgCreateInfoResult> createCustomMessageRes =await TencentImSDKPlugin.v2TIMManager.getMessageManager().createCustomMessage(data: '正在输入中',);// 发送消息时,需要把needReadReceipt设置为trueTencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessage(id: createCustomMessageRes.data.id, receiver: "", groupID: "groupID",onlineUserOnly: true,needReadReceipt: true);
V2TIMMessage
的 needReadReceipt
(Details) 字段判断消息是否需要已读回执,如果需要已读回执,当用户查看消息后,调用 sendMessageReadReceipts
(Details) 接口发送消息已读回执。V2TimCallback sendMessageReadReceipts = await TencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessageReadReceipts(messageIDList: ['msgids']);if(sendMessageReadReceipts.code == 0){// 成功}else{// 失败}
V2TimAdvancedMsgListener
的 onRecvMessageReadReceipts
(Details) 回调监听消息已读回执通知,在通知中更新 UI,例如更新为 “2 人已读”。onRecvMessageReadReceipts: (List<V2TimMessageReceipt> receiptList) {receiptList.forEach((element) {element.groupID; // 群idelement.msgID; // 已读回执消息 IDelement.readCount;// 群消息最新已读数element.unreadCount;// 群消息最新未读数element.userID; // C2C 消息对方 ID});},
V2TimessageReceipt
字段含义如下:属性 | 含义 | 说明 |
msgID | 消息 ID | 消息唯一 ID |
userID | 对端用户 ID | 如果是单聊,该字段表示对端用户 ID |
timestamp | 对端用户标记会话已读时间 | 该字段在消息已读场景无效,如果是单聊,当对端用户调用 markC2CMessageAsRead 接口标记会话已读时,自己会收到的 onRecvC2CReadReceipt 回调,回调里会携带 timestamp 信息 |
groupID | 群组 ID | 如果是群聊,该字段为群组 ID |
readCount | 群消息已读人数 | 如果是群聊,该字段为群消息已读人数 |
unreadCount | 群消息未读人数 | 如果是群聊,该字段为群消息未读人数 |
V2TimValueCallback<List<V2TimMessageReceipt>> getMessageReadReceipts = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getMessageReadReceipts(messageIDList: []);if(getMessageReadReceipts.code == 0){getMessageReadReceipts.data.forEach((element) {// 解析群消息已读回执element.groupID;element.msgID;element.readCount;element.timestamp;element.unreadCount;element.userID;});}
V2TimValueCallback<V2TimGroupMessageReadMemberList> getGroupMessageReadMemberList = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getGroupMessageReadMemberList(messageID: "", filter: GetGroupMessageReadMemberListFilter.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ,);if(getGroupMessageReadMemberList.code == 0){// 获取群消息已读未读群成员列表getGroupMessageReadMemberList.data.isFinished;getGroupMessageReadMemberList.data.memberInfoList;getGroupMessageReadMemberList.data.nextSeq;}
本页内容是否解决了您的问题?