Browse SDKs · iOS
Platform
SDKsiOS

Mark a conversation as read

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

Copy

Mark messages in a specified conversation as read using markConversationMessageAsRead:onSuccess:onFailure:. Invoke this method when the user enters a chat screen and reads active unread messages.

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation ID to mark as read.

Code example

[[OIMManager manager] markConversationMessageAsRead:@"c2c_user1002"
                                          onSuccess:^(NSString * _Nullable data) {
                                              NSLog(@"markConversationMessageAsRead success");
                                          }
                                          onFailure:^(NSInteger code, NSString *message) {
                                              NSLog(@"markConversationMessageAsRead failed: %ld %@", (long)code, message);
                                          }];

Do not invoke this method during notification banner previews or when silent background messages arrive.

Return value

The onSuccess callback confirms that OpenIMServer processed the read mark.

State changes after the call

  • Local unread reset: The unread count for this conversation resets to zero, broadcasting onConversationChanged: in OIMConversationListener.
  • Global unread reduction: The global account-level unread count decreases, notifying listeners via onTotalUnreadMessageCountChanged: (see Maintain the total unread count).
  • C2C read receipt delivery: In 1-on-1 direct conversations, the peer user receives read receipt events via onRecvC2CReadReceipt: in OIMAdvancedMsgListener:
- (void)onRecvC2CReadReceipt:(NSArray<OIMReceiptInfo *> *)items {
    [self mergeC2CReceipts:items ?: @[]];
}

Locate the target conversation using the sender identity, then mark messages as read using each clientMsgID provided in msgIDList. For group message reader tracking, refer to Send group read receipts.