Report group messages as read
Report group-message read receipts with the WASM SDK.
await openimsdk.sendGroupMessageReadReceipt({
conversationID,
clientMsgIDList: visibleUnreadMessageIDs,
});Every message in one batch must belong to the target group conversation. Promise completion means only that the server accepted the report; it does not mean other client interfaces have already updated. The conversation unread count is maintained separately through markConversationMessageAsRead().
Other clients receive member-level group read updates via SdkEvent.OnRecvGroupReadReceipt. When the event arrives, match the message using conversationID + clientMsgID and update its hasReadCount, unreadCount, and reader details:
import { SdkEvent } from '@openim/wasm-client-sdk';
const handleGroupReadReceipt = ({ data }) => {
mergeGroupReadReceipt(data);
};
openimsdk.on(SdkEvent.OnRecvGroupReadReceipt, handleGroupReadReceipt);
function removeGroupReadReceiptListener() {
openimsdk.off(SdkEvent.OnRecvGroupReadReceipt, handleGroupReadReceipt);
}Call removeGroupReadReceiptListener() when the component unmounts, the user logs out, or the active account changes. Sending group message read receipts does not replace conversation-level read status; when leaving the chat view or switching conversations, call Mark a conversation as read to clear conversation unread counts. The report Promise, the group receipt event, and the member list returned by Get members who read a group message are three independent stages.
Was this page helpful?