Browse SDKs · iOS
SDKsiOS

Mark a conversation as read

Mark messages in a specified conversation as read with OpenIM iOS SDK.

Copy

Call the API after the user opens the conversation and reads the currently visible messages:

[[OIMManager manager] markConversationMessageAsRead:conversationID
                                           onSuccess:nil
                                           onFailure:nil];

Do not mark messages as read merely because a notification was previewed or a message arrived while the application was in the background. A successful callback means that the request has completed, not that onConversationChanged: has arrived. Merge the latest conversation by conversationID afterward, or query again if it must be confirmed immediately.

In a one-to-one chat, after the current user marks the conversation as read, the other user can receive message read receipts through onRecvC2CReadReceipt:. This page owns that delegate. First locate the one-to-one conversation by the other user's ID, then update read state using each clientMsgID in the item's msgIDList.

- (void)onRecvC2CReadReceipt:(NSArray<OIMReceiptInfo *> *)items {
    [self mergeC2CReceipts:items ?: @[]];
}

The stable listener that receives this callback must be registered with addAdvancedMsgListener: and removed with removeAdvancedMsgListener:. For the complete lifecycle, see Receive messages. In a group chat, calling this API only clears the current account's conversation unread count. For member-level receipts, see Report group-message read status.