Starter Deal! First 3 month from only  $9.9 /month!
Starter Deal! First 3 month from only  $9.9 /month!
Grab It Now 
Chat
  • Web
    • TUIKit
      • Overview
      • Installaton
        • TUIKit
          • Vue
          • React
        • TUIChat Only
          • Vue
      • Features
        • Reactions
        • Read Receipt
        • Typing Status
        • User Online Status
      • Themes
        • Setting UI Styles
          • Web
          • Mobile
      • Customization
        • Customize Messages
      • Localization
    • SDK
      • Install Chat SDK
      • Initialize Chat SDK
      • Login and Logout
      • Client APIs
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Historical Message
        • Forward Messages
        • Modify a Message
        • Delete Messages
        • Clear History Message
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Targeted Group Message
        • Do not Notify
        • Key-Value Extensions
        • Translation
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
        • Group Counter
      • Community Topic
        • Community Management
      • User Profile and Relationship Chain
        • User Profile
        • User Status
        • Friend Management
        • Friend List
        • Block List
  • Android
    • Run Demo
    • UIKit
      • Overview
      • Getting Started
      • Installation
        • TUIKit
        • TUIChat Only
      • Features
        • Reactions
        • Read Receipt
        • User Online Status
        • Search Messages
      • Customization
        • Customize Messages
        • Customize Emojis and Stickers
      • Localization
    • SDK
      • Install Chat SDK
      • Initialize Chat SDK
      • Login and Logout
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Retrieve Messages
        • Forward Messages
        • Modify a Message
        • Insert a Message
        • Delete Messages
        • Clear History Messages
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Metions
        • Targeted Group Message
        • Do not Notify
        • Key-Value Extensions
        • Reactions
        • Translation
        • Pin Messages
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Draft
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Manage Group
        • Profile
        • Manage Members
        • Member Profile
        • Attribute
        • Counter
      • Community and Topic
        • Manage Community
        • Permission Group
      • User
        • User Profile
        • User Status
        • Manage Friends
        • Friend Group
        • Block Lists
      • Local Search
        • Search Messages
        • Search Friends
        • Search Groups
        • Search Group Members
      • Signaling
      • API Reference
        • Java
  • iOS and macOS
    • Run Demo
    • UIKit
      • Overview
      • Getting Started
      • Installation
        • TUIKit
        • TUIChat Only
      • Features
        • Reactions
        • Read Receipt
        • User Online Status
        • Search Messages
      • Customization
        • Customize Messages
        • Customize Emojis and Stickers
      • Localization
    • SDK
      • Installation
        • iOS
        • macOS
      • Initialize Chat SDK
      • Login and Logout
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Retrieve Messages
        • Forward Messages
        • Modify a Message
        • Insert a Message
        • Delete Messages
        • Clear History Messages
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Metions
        • Targeted Group Messages
        • Do not Notify
        • Key-Value Extensions
        • Reactions
        • Translation
        • Pin Messages
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Draft
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Manage Group
        • Profile
        • Manage Members
        • Member Profile
        • Attribute
        • Counter
      • Community and Topic
        • Manage Community
        • Permission Group
      • User
        • User Profile
        • User Status
        • Manage Friends
        • Friend Group
        • Block Lists
      • Local Search
        • Search Messages
        • Search Friends
        • Search Groups
        • Search Group Members
      • Signaling
      • API Reference
        • Swift
        • Objective-C
  • Windows
    • SDK
      • Install Chat SDK
      • Initialize Chat SDK
      • Login and Logout
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Retrieve Messages
        • Forward Messages
        • Modify a Message
        • Insert a Message
        • Delete Messages
        • Clear History Messages
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Metions
        • Targeted Group Messages
        • Do not Notify
        • Key-Value Extensions
        • Reactions
        • Translation
        • Pin Messages
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Draft
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Manage Group
        • Profile
        • Manage Members
        • Member Profile
        • Attribute
        • Counter
      • Community and Topic
        • Manage Community
        • Permission Group
      • User
        • User Profile
        • User Status
        • Manage Friends
        • Friend Group
        • Block Lists
      • Local Search
        • Search Messages
        • Search Friends
        • Search Groups
        • Search Group Members
      • Signaling
      • API Reference
        • C++
        • C
  • Flutter
    • Run Demo
    • UIKIT
      • Overview
      • Installation
        • integrated
      • Features
        • Local Search
        • Offline Push
        • Online Status
        • Typing Status
        • Message Read Receipt
        • Message Reactions
        • Internationalization
        • Adding Custom Messages
        • Emoji & Stickers
      • Customization
        • Modifying UI Themes
        • Setting UI Styles
    • SDK
      • Install Chat SDK
        • Install
      • Initialize Chat SDK
        • Initialize
      • Login And Logout
        • Login and Logout
      • Message
        • Message Overview
        • Sending Message
        • Receiving Message
        • Historical Message
        • Forwarding Message
        • Modifying Message
        • Message Inserting
        • Deleting Message
        • Clearing Messages
        • Recalling Message
        • Online Message
        • Read Receipt
        • Querying Message
        • Group @ Message
        • Targeted Group Message
        • Notification Muting
        • Message Extension
      • Conversation
        • Conversation Overview
        • Conversation List
        • Getting Conversation
        • Conversation Unread Count
        • Pinning Conversation to the Top
        • Deleting Conversation
        • Conversation Draft
        • Conversation Group
      • Group
        • Group Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
      • User
        • User Profile
        • Friend Management
        • Friend List
        • Blocklist
      • Offline Push
        • Offline Push
      • Signaling
        • Signaling Management
      • Local Search
        • Searching for Message
        • Searching for Friend
        • Searching Group
        • Searching for Group Member
      • API Reference
        • Client APIs
  • React Native
    • Run Demo
    • SDK
      • SDK Integration
      • Initialization
      • Login and Logout
      • Message
        • Message Overview
        • Sending Message
        • Receiving Message
        • Historical Message
        • Forwarding Message
        • Modifying Message
        • Message Inserting
        • Deleting Message
        • Clearing Messages
        • Recalling Message
        • Online Message
        • Read Receipt
        • Querying Message
        • Group @ Message
        • Targeted Group Message
        • Notification Muting
        • Message Extension
      • Group
        • Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
        • Community Management
      • User
        • User Profile
        • Friend Management
        • Friend List
        • Blocklist
      • Offline Push
        • Offline Push
      • Local Search
        • Searching for Message
        • Searching for Friend
        • Searching Group
        • Searching for Group Member
      • Signaling
        • Signaling Management
  • Unity(Game Solution)
    • Run Demo
    • SDK
      • SDK Integration
      • Initialization
      • Login and Logout
      • Message
        • Message Overview
        • Sending Message
        • Receiving Message
        • Historical Message
        • Forwarding Message
        • Modifying Message
        • Deleting Message
        • Clearing Messages
        • Recalling Message
        • Online Message
        • Read Receipt
        • Querying Message
        • Group @ Message
        • Targeted Group Message
        • Notification Muting
        • Message Extension
      • Conversation
        • Conversation Overview
        • Conversation List
        • Getting Conversation
        • Conversation Unread Count
        • Pinning Conversation to the Top
        • Deleting Conversation
        • Conversation Draft
        • Conversation Mark
        • Conversation Group
      • Group
        • Group Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
        • Group Counter
      • User
        • User Profile
        • User Status
        • Friend Management
        • Friend List
        • Blocklist
  • Unreal Engine(Game Solution)
    • SDK
      • SDK Integration
  • Free Demos
  • Server APIs
    • Generating UserSig
    • RESTful APIs
      • RESTful API Overview
      • RESTful API List
      • Message Related
        • Send Message
          • Sending One-to-One Messages to One User
          • Sending One-to-One Messages to Multiple Users
          • Sending Ordinary Messages in a Group
          • Sending System Messages in a Group
          • Broadcast Message of Audio-Video Group
          • Importing One-to-One Messages
          • Importing Group Messages
        • Historical Message
          • Modifying Historical One-to-one Messages
          • Modifying Historical Group Messages
          • Pulling Historical One-to-one Messages
          • Pulling Historical Group Messages
        • Delete Message
          • Deleting Messages Sent by a Specified User
        • Withdraw Message
          • Recalling One-to-One Messages
          • Recalling Group Messages
        • Read Receipt
          • Marking One-to-One Messages as Read
          • Pulling Group Message Read Receipt Details
          • Pulling Read Receipts for Group Messages
        • Message Extension
          • Pulling the Message Extension of a One-to-One Message
          • Configuring Message Extension for a One-to-One Message
          • Pulling Message Extension of a Group Message
          • Configuring Message Extension for a Group Message
        • Pushing to All Users
          • API for Pushing to All Users
          • Pushing to All Users
          • Setting Application Attribute Names
          • Getting Application Attribute Names
          • Getting User Attributes
          • Setting User Attributes
          • Deleting User Attributes
          • Getting User Tags
          • Adding User Tags
          • Deleting User Tags
          • Deleting All Tags of a User
      • Session Related
        • Conversation List
          • Pulling a conversation list
        • Session Unread Count
          • Setting the Unread Message Count of a Member
          • Querying Unread One-to-One Message Count
        • Delete Session
          • Deleting a conversation
        • Session Grouping Tag
          • Creating Conversation Group Data
          • Updating Conversation Group Data
          • Deleting Conversation Group Data
          • Creating or Updating Conversation Mark Data
          • Searching for Conversation Group Marks
          • Pulling Conversation Group Mark Data
      • Group Related
        • Group Management
          • Getting All Groups in an App
          • Creating a Group
          • Disbanding a Group
          • Getting the Groups a User Has Joined
        • Group Information
          • Getting Group Profiles
          • Modifying the Profile of a Group
          • Importing a Group Profile
        • Group Member Management
          • Adding Group Members
          • Deleting Group Members
          • Banning Group Members
          • Unbanning Group Members
          • Bulk Muting and Unmuting
          • Getting the List of Muted Group Members
          • Changing Group Owner
          • Querying the Roles of Users in a Group
          • Importing Group Members
        • Group Member Information
          • Getting Group Member Profiles
          • Modifying the Profile of a Group Member
        • Group Custom Attributes
          • Getting Group Custom Attributes
          • Modifying Group Custom Attributes
          • Clearing Group Custom Attributes
          • Resetting Group Custom Attributes
          • Deleting Group Custom Attributes
        • Live Group Management
          • Getting the Number of Online Users in an Audio-Video Group
          • Getting the List of Online Members in Audio-Video Group
          • Setting Audio-Video Group Member Marks
          • Getting the List of Banned Group Members.
        • Community Management
          • Creating Topic
          • Deleting Topic
          • Getting Topic Profile
          • Modifying Topic Profile
          • Importing Topic Profiles
        • Group Counter
          • Getting Group Counters
          • Updating Group Counters
          • Deleting Group Counters
      • User Management
        • Account Management
          • Importing a Single Account
          • Importing Multiple Accounts
          • Deleting Accounts
          • Querying Accounts
        • User Information
          • Setting Profiles
          • Pulling Profiles
        • User Status
          • Invalidating Account Login States
          • Querying Account Online Status
        • Friend Management
          • Adding Friends
          • Importing Friends
          • Updating Friends
          • Deleting Friends
          • Deleting All Friends
          • Verifying Friends
          • Pulling Friends
          • Pulling Specified Friends
        • Friend Lists
          • Adding Lists
          • Deleting Lists
          • Pulling Lists
        • Blocklist
          • Blocklisting Users
          • Unblocklisting Users
          • Pulling a Blacklist
          • Verifying Users on a Blocklist
      • Global Mute Management
        • Setting Global Mute
        • Querying Global Mute
      • Operations Management
        • Pulling Operations Data
        • Downloading Recent Messages
        • Getting Server IP Addresses
      • Chatbots
        • Pulling Chatbot Accounts
        • Creating Chatbot Accounts
        • Deleting Chatbot Accounts
    • Webhooks
      • Webhook Overview
      • Webhook Command List
      • Operations Management Callbacks
        • API Overclocking Alarm Callbacks
      • Online Status Webhooks
        • Status Change Webhooks
      • Relationship Chain Webhooks
        • After a Profile Is Updated
        • Before a Friend Is Added
        • Before a Friend Request Is Responded
        • After a Friend Is Added
        • After a Friend Is Deleted
        • After a User Is Added to Blocklist
        • After a User Is Removed from Blocklist
      • One-to-One Message Webhooks
        • Before a One-to-One Message Is Sent
        • After a One-to-One Message Is Sent
        • After a One-to-One message Is Marked as Read
        • After A One-to-One Message Is Recalled
      • Group Webhooks
        • Before a Group Is Created
        • After a Group Is Created
        • Before Applying to Join a Group
        • Before Inviting a User to a Group
        • After a User Joins a Group
        • After a User Leaves a Group
        • Before Group Message Is Sent
        • After a Group Message Is Sent
        • After a Group Is Full
        • After a Group Is Disbanded
        • After Group Profile Is Modified
        • Callback After Recalling Group Messages
        • Webhook for Online and Offline Status of Audio-Video Group Members
        • Webhook for Exceptions When Group Messages Are Sent
        • Before a Topic Is Created
        • After a Topic Is Created
        • After a Topic Is Deleted
        • Topic Profile Change Webhook
        • Callback After Group Member Profile Changed
        • Callback After Group Attribute Changed
        • Callback After Read Receipt
        • Callback After the Group Owner Changed
      • Webhook Mutual Authentication Configuration Guide
        • Apache Mutual Authentication Configuration
        • Nginx Mutual Authentication Configuration
      • Chatbot webhooks
        • Chatbot Passthrough Message Callback
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes
Chat

Message Read Receipt

Feature Description

If a message sender wants to know who has or has not read the message, the sender needs to enable the message read receipt feature. After this feature is enabled, the sender can set whether a message requires a read receipt when sending the message; if yes, the sender will receive a receipt after the message is read by the receiver.
Read receipts are supported for both one-to-one and group messages in the same way.
Note
To use this feature, you need to purchase the Premium edition.
Read receipts for group messages are supported only by the Enhanced edition on v6.1.2155 or later.
Read receipts for one-to-one messages are supported only by the Enhanced edition on v6.2.2363 or later.

Message Read Receipt

Specifying a group type for which to support message read receipts

Log in to the IM console, select Feature Configuration > Login and Message > Group Message Read Receipts.
You don't need to configure read receipts to be sent for one-to-one messages in the console, as they are supported by default.

Specifying that a message requires a read receipt (by the sender)

After creating a message, the sender specifies that the message requires a read receipt through the needReadReceipt field in V2TIMMessage (Android / iOS and macOSWindows) and then sends the message to the conversation.
Sample code:
Android
iOS and macOS
Windows
V2TIMMessage message = V2TIMManager.getMessageManager().createTextMessage("Group message read receipt");
// Specify that the message requires a read receipt
message.setNeedReadReceipt(true);
// Send the message
V2TIMManager.getMessageManager().sendMessage(message, null, "groupA", V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onProgress(int progress) {
}

@Override
public void onSuccess(V2TIMMessage message) {
}

@Override
public void onError(int code, String desc) {
}
});
/// Sample API call
V2TIMMessage *message = [[V2TIMManager sharedInstance] createTextMessage:@"Group message read receipt"];
// Specify that the message requires a read receipt
message.needReadReceipt = YES;
// Send the message
[[V2TIMManager sharedInstance] sendMessage:message receiver:nil groupID:@"groupA" priority:V2TIM_PRIORITY_NORMAL onlineUserOnly:NO offlinePushInfo:nil progress:nil succ:nil fail:nil];
class SendCallback final : public V2TIMSendCallback {
public:
using SuccessCallback = std::function<void(const V2TIMMessage&)>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;
using ProgressCallback = std::function<void(uint32_t)>;

SendCallback() = default;
~SendCallback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback,
ProgressCallback progress_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
progress_callback_ = std::move(progress_callback);
}

void OnSuccess(const V2TIMMessage& message) override {
if (success_callback_) {
success_callback_(message);
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}
void OnProgress(uint32_t progress) override {
if (progress_callback_) {
progress_callback_(progress);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
ProgressCallback progress_callback_;
};

V2TIMMessage message = V2TIMManager::GetInstance()->GetMessageManager()->CreateTextMessage(u8"Group message read receipt");
// Specify that the message requires a read receipt
message.setNeedReadReceipt(true);

auto callback = new SendCallback{};
callback->SetCallback([=](const V2TIMMessage& message) { delete callback; },
[=](int error_code, const V2TIMString& error_message) { delete callback; },
[=](uint32_t progress) {});

V2TIMManager::GetInstance()->GetMessageManager()->SendMessage(
message, "groupA", {}, V2TIMMessagePriority::V2TIM_PRIORITY_DEFAULT, false, {}, callback);

Sending a message read receipt (by the receiver)

After receiving the message, the receiver determines whether the message requires a read receipt based on the needReadReceipt field in V2TIMMessage. If yes, after the user reads the message, the receiver calls the sendMessageReadReceipts API (Android / iOS and macOSWindows) to send a message read receipt.
Sample code:
Android
iOS and macOS
Windows
// Suppose the user has read the `message` message
if (!message.isSelf() && message.isNeedReadReceipt()) {
List<V2TIMMessage> messageList = new ArrayList<>();
messageList.add(message);
V2TIMManager.getMessageManager().sendMessageReadReceipts(messageList, new V2TIMCallback() {
@Override
public void onSuccess() {
// Read receipt for the message sent successfully
}

@Override
public void onError(int code, String desc) {
// Failed to send a read receipt for the message
}
});
}
/// Sample API call
/// Suppose the user has read the `msg` message
if (!msg.isSelf && msg.needReadReceipt) {
[[V2TIMManager sharedInstance] sendMessageReadReceipts:@[msg] succ:^{
// Read receipt for the message sent successfully
} fail:^(int code, NSString *desc) {
// Failed to send a read receipt for the message
}];
}
class Callback final : public V2TIMCallback {
public:
using SuccessCallback = std::function<void()>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;

Callback() = default;
~Callback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}

void OnSuccess() override {
if (success_callback_) {
success_callback_();
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};

auto callback = new Callback;
callback->SetCallback(
[=]() {
// Read receipt for the message sent successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to send a read receipt for the message
delete callback;
});

// Suppose the user has read the `message` message
if (!message.isSelf && message.needReadReceipt) {
V2TIMMessageVector messageList;
messageList.PushBack(message);
V2TIMManager::GetInstance()->GetMessageManager()->SendMessageReadReceipts(messageList, callback);
}

Listening for a message read receipt notification (by the sender)

After the receiver sends a message read receipt, the sender will receive the read receipt notification in onRecvMessageReadReceipts of V2TIMAdvancedMsgListener (Android / iOS and macOSWindows) and update the UI based on the notification to display the message as, for example, "Read by two members".
Sample code:
Android
iOS and macOS
Windows
V2TIMAdvancedMsgListener advancedMsgListener = new V2TIMAdvancedMsgListener() {
@Override
public void onRecvMessageReadReceipts(List<V2TIMMessageReceipt> receiptList) {
for (V2TIMMessageReceipt receipt : receiptList) {
// Message ID
String msgID = receipt.getMsgID();
// ID of the other party of the one-to-one message
String userID = receipt.getUserID();
// Read status of the other party of the one-to-one message
boolean isPeerRead = receipt.isPeerRead();
// Latest read count of the group message
long readCount = receipt.getReadCount();
// Latest unread count of the group message
long unreadCount = receipt.getUnreadCount();
}
}
};
V2TIMManager.getMessageManager().addAdvancedMsgListener(advancedMsgListener);
/// Sample API call
[[V2TIMManager sharedInstance] addAdvancedMsgListener:self];
- (void)onRecvMessageReadReceipts:(NSArray<V2TIMMessageReceipt *> *)receiptList {
for(V2TIMMessageReceipt *receipt in receiptList) {
// Message ID
NSString *msgID = receipt.msgID;
// ID of the other party of the one-to-one message
NSString * userID = receipt.userID;
// Read status of the other party of the one-to-one message
BOOL isPeerRead = receipt.isPeerRead;
// Group ID
NSString * groupID = receipt.groupID;
// Latest read count of the group message
uint64_t readCount = receipt.readCount;
// Latest unread count of the group message
uint64_t unreadCount = receipt.unreadCount;
}
}
class AdvancedMsgListener final : public V2TIMAdvancedMsgListener {
public:
void OnRecvMessageReadReceipts(const V2TIMMessageReceiptVector& receiptList) override {
for (size_t i = 0; i < receiptList.Size(); ++i) {
const V2TIMMessageReceipt& receipt = receiptList[i];
// Message ID
V2TIMString msgID = receipt.msgID;
// ID of the other party of the one-to-one message
V2TIMString userID = receipt.userID;
// Read status of the other party of the one-to-one message
bool isPeerRead = receipt.isPeerRead;
// Latest read count of the group message
int32_t readCount = receipt.readCount;
// Latest unread count of the group message
int32_t unreadCount = receipt.unreadCount;
}
}
// Other members ...
};

// Note that `advancedMsgListener` should not be released before the IM SDK is uninitialized,
// otherwise the message callback cannot be called.
AdvancedMsgListener advancedMsgListener;
V2TIMManager::GetInstance()->GetMessageManager()->AddAdvancedMsgListener(&advancedMsgListener);

Pulling message read receipt information (by the sender)

After entering the message list, the sender pulls historical messages first, and then calls the getMessageReadReceipts API (Android / iOS and macOSWindows) to pull the message read receipt information.
The V2TIMMessageReceipt field of the message read receipt is as described below:
Attribute
Definition
Description
msgID
Message ID
Unique message ID
userID
ID of the receiver
If the message is a one-to-one message, this field indicates the ID of the receiver.
isPeerRead
Whether the message is read by the receiver
If the message is a one-to-one message, this field indicates whether the message is read by the receiver.
timestamp
Time when the receiver marks the message as read
This field is invalid when a message is read. If the message is a one-to-one message, when the receiver calls the markC2CMessageAsRead API to mark the message as read, the sender will receive the onRecvC2CReadReceipt callback which contains the timestamp information. Usage of markC2CMessageAsRead: Conversation Unread Count.
groupID
Group ID
If the message is a group message, this field indicates the group ID.
readCount
Number of members who have read the group message
If the message is a group message, this field indicates the number of members who have read the message.
unreadCount
Number of members who have not read the group message
If the message is a group message, this field indicates the number of members who have not read the message.
Sample code:
Android
iOS and macOS
Windows
/// Sample API call (taking a group message as an example)
V2TIMManager.getMessageManager().getGroupHistoryMessageList("groupA", 20, null, new V2TIMValueCallback<List<V2TIMMessage>>() {
@Override
public void onSuccess(final List<V2TIMMessage> v2TIMMessages) {
List<V2TIMMessage> receiptMsgs = new ArrayList<>();
// If the message sent by you requires a read receipt, the message read receipt information will need to be pulled.
for (V2TIMMessage msg : v2TIMMessages) {
if (msg.isSelf() && msg.isNeedReadReceipt()) {
receiptMsgs.add(msg);
}
}
V2TIMManager.getMessageManager().getMessageReadReceipts(receiptMsgs, new V2TIMValueCallback<List<V2TIMMessageReceipt>>() {
@Override
public void onSuccess(List<V2TIMMessageReceipt> v2TIMMessageReceipts) {
Map<String, V2TIMMessageReceipt> messageReceiptMap = new HashMap<>();
for (V2TIMMessageReceipt receipt : v2TIMMessageReceipts) {
messageReceiptMap.put(receipt.getMsgID(), receipt);
}
for (V2TIMMessage msg : v2TIMMessages) {
V2TIMMessageReceipt receipt = messageReceiptMap.get(msg.getMsgID());
if (receipt != null) {
// ID of the other party of the one-to-one message
String userID = receipt.getUserID();
// Read status of the other party of the one-to-one message
boolean isPeerRead = receipt.isPeerRead();
// Group ID
String groupID = receipt.getGroupID();
// Message read count. If `readCount` is `0`, no one has read the message.
long readCount = receipt.getReadCount();
// Message unread count. If `unreadCount` is `0`, all members have read the message.
long unreadCount = receipt.getUnreadCount();
}
}
}

@Override
public void onError(int code, String desc) {
// Failed to pull the message read status
}
});
}

@Override
public void onError(int code, String desc) {
// Failed to pull the message
}
});
/// Sample API call (taking a group message as an example)
[[V2TIMManager sharedInstance] getGroupHistoryMessageList:@"groupA" count:20 lastMsg:nil succ:^(NSArray<V2TIMMessage *> *msgs) {
NSMutableArray *receiptMsgs = [NSMutableArray array];
// If the message sent by you requires a read receipt, the message read receipt information will need to be pulled.
for (V2TIMMessage *msg in msgs) {
if (msg.isSelf && msg.needReadReceipt) {
[receiptMsgs addObject:msg];
}
}
[[V2TIMManager sharedInstance] getMessageReadReceipts:receiptMsgs succ:^(NSArray<V2TIMMessageReceipt *> *receiptList) {
NSMutableDictionary *param = [NSMutableDictionary dictionary];
for (V2TIMMessageReceipt *receipt in receiptList) {
[param setObject:receipt forKey:receipt.msgID];
}
for (V2TIMMessage *msg in msgs) {
V2TIMMessageReceipt *receipt = param[msg.msgID];
// ID of the other party of the one-to-one message
NSString * userID = receipt.userID;
// Read status of the other party of the one-to-one message
BOOL isPeerRead = receipt.isPeerRead;
// Group ID
NSString * groupID = receipt.groupID;
// Message read count. If `readCount` is `0`, no one has read the message.
uint64_t readCount = receipt.readCount;
// Message unread count. If `unreadCount` is `0`, all members have read the message.
uint64_t unreadCount = receipt.unreadCount;
}
} fail:^(int code, NSString *desc) {
// Failed to pull the message read status
}];
} fail:^(int code, NSString *desc) {
// Failed to pull the message
}];
template <class T>
class ValueCallback final : public V2TIMValueCallback<T> {
public:
using SuccessCallback = std::function<void(const T&)>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;

ValueCallback() = default;
~ValueCallback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}

void OnSuccess(const T& value) override {
if (success_callback_) {
success_callback_(value);
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};

// Sample API call (taking a group message as an example)
V2TIMMessageListGetOption option;
option.getType = V2TIMMessageGetType::V2TIM_GET_CLOUD_OLDER_MSG;
option.count = 20;
option.groupID = "groupA";

auto callback = new ValueCallback<V2TIMMessageVector>{};
callback->SetCallback(
[=](const V2TIMMessageVector& messageList) {
V2TIMMessageVector receiptMsgs;
for (size_t i = 0; i < messageList.Size(); ++i) {
const V2TIMMessage& message = messageList[0];
// If the message sent by you requires a read receipt,
// the message read receipt information will need to be pulled.
if (message.isSelf && message.needReadReceipt) {
receiptMsgs.PushBack(message);
}
}

auto receipt_callback = new ValueCallback<V2TIMMessageReceiptVector>{};
receipt_callback->SetCallback(
[=](const V2TIMMessageReceiptVector& receiptList) {
std::unordered_map<V2TIMString, V2TIMMessageReceipt> map;
for (size_t i = 0; i < receiptList.Size(); ++i) {
const V2TIMMessageReceipt& receipt = receiptList[i];
map[receipt.msgID] = receipt;
}
for (size_t i = 0; i < messageList.Size(); ++i) {
const V2TIMMessage& message = messageList[0];
if (map.count(message.msgID)) {
const V2TIMMessageReceipt& receipt = map[message.msgID];
// ID of the other party of the one-to-one message
V2TIMString userID = receipt.userID;
// Read status of the other party of the one-to-one message
bool isPeerRead = receipt.isPeerRead;
// Group ID
V2TIMString groupID = receipt.groupID;
// Message read count. If `readCount` is `0`, no one has read the message.
int32_t readCount = receipt.readCount;
// Message unread count. If `unreadCount` is `0`, all members have read the message.
int32_t unreadCount = receipt.unreadCount;
}
const V2TIMMessageReceipt& receipt = receiptList[i];
}

delete receipt_callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to pull the message read status
delete receipt_callback;
});

V2TIMManager::GetInstance()->GetMessageManager()->GetMessageReadReceipts(messageList, receipt_callback);

delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to pull the message
delete callback;
});

V2TIMManager::GetInstance()->GetMessageManager()->GetHistoryMessageList(option, callback);

Pulling the list of members who have or have not read a group message (by the sender)

To view the list of members who have or have not read a group message, the sender can call the getGroupMessageReadMemberList API (Android / iOS and macOSWindows) to pull the member list by page.
Android
iOS and macOS
Windows
/// Sample API call
V2TIMManager.getMessageManager().getGroupMessageReadMemberList(message, V2TIMMessage.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ, 0, 100, new V2TIMValueCallback<V2TIMGroupMessageReadMemberList>() {
@Override
public void onSuccess(V2TIMGroupMessageReadMemberList v2TIMGroupMessageReadMemberList) {
// `members` is the list of members who have read the message pulled from the current page.
List<V2TIMGroupMemberInfo> members = v2TIMGroupMessageReadMemberList.getMemberInfoList();
// `nextSeq` indicates the cursor position for the next pull.
long nextSeq = v2TIMGroupMessageReadMemberList.getNextSeq();
// `isFinished` indicates whether the list of members who have read the message has been fully pulled.
boolean isFinished = v2TIMGroupMessageReadMemberList.isFinished();
// If the list of members who have read the message is not fully pulled, continue with the next pull (here is only the sample code. We recommend paged pull be triggered by a user click).
if (!isFinished) {
V2TIMManager.getMessageManager().getGroupMessageReadMemberList(message, V2TIMMessage.V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ, nextSeq, 100, new V2TIMValueCallback<V2TIMGroupMessageReadMemberList>() {
@Override
public void onSuccess(V2TIMGroupMessageReadMemberList v2TIMGroupMessageReadMemberList) {
// List of members who have read the message pulled successfully
}

@Override
public void onError(int code, String desc) {
// Failed to pull the list of members who have read the message
}
});
}
}

@Override
public void onError(int code, String desc) {
// Failed to pull the list of members who have read the message
}
});
/// Sample API call
[[V2TIMManager sharedInstance] getGroupMessageReadMemberList:message filter:V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ nextSeq:0 count:100 succ:^(NSMutableArray<V2TIMGroupMemberInfo *> *members, uint64_t nextSeq, BOOL isFinished) {
// `members` is the list of members who have read the message pulled from the current page.
// `nextSeq` indicates the cursor position for the next pull.
// `isFinished` indicates whether the list of members who have read the message has been fully pulled.
// If the list of members who have read the message is not fully pulled, continue with the next pull (here is only the sample code. We recommend paged pull be triggered by a user click).
if (!isFinished) {
[[V2TIMManager sharedInstance] getGroupMessageReadMemberList:message filter:V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ nextSeq:nextSeq count:100 succ:^(NSMutableArray<V2TIMGroupMemberInfo *> *members, uint64_t nextSeq, BOOL isFinished) {
// List of members who have read the message pulled successfully
} fail:^(int code, NSString *desc) {
// Failed to pull the list of members who have read the message
}];
}
} fail:^(int code, NSString *desc) {
// Failed to pull the list of members who have read the message
}];
template <class T>
class ValueCallback final : public V2TIMValueCallback<T> {
public:
using SuccessCallback = std::function<void(const T&)>;
using ErrorCallback = std::function<void(int, const V2TIMString&)>;

ValueCallback() = default;
~ValueCallback() override = default;

void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
success_callback_ = std::move(success_callback);
error_callback_ = std::move(error_callback);
}

void OnSuccess(const T& value) override {
if (success_callback_) {
success_callback_(value);
}
}
void OnError(int error_code, const V2TIMString& error_message) override {
if (error_callback_) {
error_callback_(error_code, error_message);
}
}

private:
SuccessCallback success_callback_;
ErrorCallback error_callback_;
};

auto callback = new ValueCallback<V2TIMGroupMessageReadMemberList>{};
callback->SetCallback(
[=](const V2TIMGroupMessageReadMemberList& groupMessageReadMemberList) {
// `members` is the list of members who have read the message pulled from the current page.
const V2TIMGroupMemberInfoVector& members = groupMessageReadMemberList.members;
// `nextSeq` indicates the cursor position for the next pull.
uint64_t nextSeq = groupMessageReadMemberList.nextSeq;
// `isFinished` indicates whether the list of members who have read the message has been fully pulled.
bool isFinished = groupMessageReadMemberList.isFinished;
// If the list of members who have read the message is not fully pulled,
// continue with the next pull (here is only the sample code.
// We recommend paged pull be triggered by a user click).
if (!isFinished) {
auto callback = new ValueCallback<V2TIMGroupMessageReadMemberList>{};
callback->SetCallback(
[=](const V2TIMGroupMessageReadMemberList& groupMessageReadMemberList) {
// List of members who have read the message pulled successfully
delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to pull the list of members who have read the message
delete callback;
});
V2TIMManager::GetInstance()->GetMessageManager()->GetGroupMessageReadMemberList(
message, V2TIMGroupMessageReadMembersFilter::V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ,
nextSeq, 100, callback);
}

delete callback;
},
[=](int error_code, const V2TIMString& error_message) {
// Failed to pull the list of members who have read the message
delete callback;
});

V2TIMManager::GetInstance()->GetMessageManager()->GetGroupMessageReadMemberList(
message, V2TIMGroupMessageReadMembersFilter::V2TIM_GROUP_MESSAGE_READ_MEMBERS_FILTER_READ, 0, 100,
callback);