Mark conversation as read
Mark all received messages in a designated conversation as read.
Invoke this method only after the user actively views the message history; do not prematurely clear unread badges during background push notifications or preview popups:
Code example
import sdk, {
EventOnRecvC2CReadReceiptData,
MarkConversationMessageAsReadReq,
OpenIMSDKEvent,
} from '@openimsdk/imsdk';
const request: MarkConversationMessageAsReadReq = {
conversationID: conversationID,
};
await sdk.markConversationMessageAsRead(request);
const handleC2CReceipt = (data: EventOnRecvC2CReadReceiptData): void => {
for (let index = 0; index < data.msgReceiptList.length; index += 1) {
mergeC2CReadReceipt(data.msgReceiptList[index]);
}
};
const unsubscribeReceipt = sdk.on(OpenIMSDKEvent.EventOnRecvC2CReadReceipt, handleC2CReceipt);
export function removeC2CReadReceiptListener(): void {
unsubscribeReceipt();
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
Return value
Returns a Promise that resolves to void when the read receipt is submitted.
State changes after the call
Resolving the Promise marks the conversation as read locally. The SDK emits EventOnConversationChanged to update the conversation's unread counter; match the item by conversationID to reset badges, as shown in Retrieve conversation list. In direct chats, the remote peer receives EventOnRecvC2CReadReceipt to update checkmark indicators for sent messages. Group read receipts are handled separately via Send group read receipts. Remove the receipt listener with removeC2CReadReceiptListener() on logout.
Was this page helpful?