> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-v6-beta2-flutter-uikit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Delivery & Read Receipts

> Learn how to mark messages as delivered, read, or unread and listen for real-time receipt events using the CometChat React Native SDK.

<Info>
  **Quick Reference** - Mark messages and listen for receipts:

  ```javascript theme={null}
  // Mark as delivered
  CometChat.markAsDelivered(message);

  // Mark as read
  CometChat.markAsRead(message);

  // Listen for receipts
  CometChat.addMessageListener("LISTENER_ID", new CometChat.MessageListener({
    onMessagesDelivered: (receipt) => console.log("Delivered", receipt),
    onMessagesRead: (receipt) => console.log("Read", receipt),
  }));
  ```
</Info>

<Note>
  **Available via:** [SDK](/sdk/react-native/delivery-read-receipts) | [REST API](/rest-api/conversations/mark-user-conversation-as-delivered) | [UI Kits](/ui-kit/react-native/overview)
</Note>

## Mark Messages as Delivered

*In other words, as a recipient, how do I inform the sender that I've received a message?*

You can mark the messages for a particular conversation as read using the `markAsDelivered()` method. This method takes the below parameters as input:

| Parameter      | Information                                                                                                                                                                         |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messageId`    | The ID of the message above which all the messages for a particular conversation are to be marked as read.                                                                          |
| `receiverId`   | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id. |
| `receiverType` | Type of the receiver. Could be either of the two values( user or group).                                                                                                            |
| `senderId`     | The `UID` of the sender of the message.                                                                                                                                             |

Messages for both user & group conversations can be marked as read using this method.

Ideally, you would like to mark all the messages as delivered for any conversation when the user opens the chat window for that conversation. This includes two scenarios:

1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message ID of that message to the markAsDelivered() method.
2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message ID of the message and pass it to the markAsDelivered() method.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    var messageId = "MESSAGE_ID";
    var receiverId = "MESSAGE_RECEIVER_UID";
    var receiverType = "user";
    var senderId = "MESSAGE_SENDER_UID";
    CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    var messageId = "MESSAGE_ID";
    var receiverId = "MESSAGE_RECEIVER_GUID";
    var receiverType = "group";
    var senderId = "MESSAGE_SENDER_UID";
    CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_RECEIVER_UID";
    var receiverType: string = "user";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_RECEIVER_GUID";
    var receiverType: string = "group";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>
</Tabs>

This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as delivered.

In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    CometChat.markAsDelivered(
      message.getId(),
      message.getSender().getUid(),
      "user",
      message.getSender().getUid()
    ).then(
      () => {
        console.log("mark as delivered success.");
      },
      (error) => {
        console.log(
          "An error occurred when marking the message as delivered.",
          error
        );
      }
    );
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    CometChat.markAsDelivered(
      message.getId(),
      message.getReceiverUid(),
      "group",
      message.getSender().getUid()
    ).then(
      () => {
        console.log("mark as delivered success.");
      },
      (error) => {
        console.log(
          "An error occurred when marking the message as delivered.",
          error
        );
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_SENDER_UID";
    var receiverType: string = "user";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(
      () => {
        console.log("mark as delivered success.");
      },
      (error: CometChat.CometChatException) => {
        console.log(
          "An error occurred when marking the message as delivered.",
          error
        );
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_RECEIVER_GUID";
    var receiverType: string = "group";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then(
      () => {
        console.log("mark as delivered success.");
      },
      (error: CometChat.CometChatException) => {
        console.log(
          "An error occurred when marking the message as delivered.",
          error
        );
      }
    );
    ```
  </Tab>
</Tabs>

Another option the CometChat SDK provides is to pass the entire message object to the markAsDelivered() method.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.markAsDelivered(message);
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let message: CometChat.BaseMessage;
    CometChat.markAsDelivered(message);
    ```
  </Tab>
</Tabs>

In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.markAsDelivered(message).then(
      () => {
        console.log("mark as delivered success.");
      },
      (error) => {
        console.log(
          "An error occurred when marking the message as delivered.",
          error
        );
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let message: CometChat.BaseMessage;
    CometChat.markAsDelivered(message).then(
      () => {
        console.log("mark as delivered success.");
      },
      (error: CometChat.CometChatException) => {
        console.log(
          "An error occurred when marking the message as delivered.",
          error
        );
      }
    );
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `markAsDelivered()` returns a confirmation object:

  | Parameter   | Type   | Description                           | Sample Value |
  | ----------- | ------ | ------------------------------------- | ------------ |
  | `messageId` | string | ID of the message marked as delivered | `"25323"`    |
  | `type`      | string | Message type                          | `"text"`     |
</Accordion>

## Mark Messages as Read

*In other words, as a recipient, how do I inform the sender I've read a message?*

You can mark the messages for a particular conversation as read using the `markAsRead()` method. This method takes the below parameters as input:

| Parameter      | Information                                                                                                                                                                        |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `messageId`    | The ID of the message above which all the messages for a particular conversation are to be marked as read.                                                                         |
| `receiverId`   | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id |
| `receiverType` | Type of the receiver. Could be either of the two values( user or group)                                                                                                            |
| `senderId`     | The `UID` of the sender of the message.                                                                                                                                            |

Messages for both user and group conversations can be marked as read using this method.

Ideally, you would like to mark all the messages as read for any conversation when the user opens the chat window for that conversation. This includes two scenarios:

1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message ID of that message to the markAsRead() method.
2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message ID of the message and pass it to the markAsRead() method

<Tabs>
  <Tab title="To User">
    ```
    var messageId = "MESSAGE_ID";
    var receiverId = "MESSAGE_SENDER_UID";
    var receiverType = "user";
    var senderId = "MESSAGE_SENDER_UID";
    CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>

  <Tab title="To Group">
    ```
    var messageId = "MESSAGE_ID";
    var receiverId = "MESSAGE_RECEIVER_GUID";
    var receiverType = "group";
    var senderId = "MESSAGE_SENDER_UID";
    CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_SENDER_UID";
    var receiverType: string = "user";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_RECEIVER_GUID";
    var receiverType: string = "group";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsRead(messageId, receiverId, receiverType, senderId);
    ```
  </Tab>
</Tabs>

This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as read.

In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    CometChat.markAsRead(
      message.getId(),
      message.getSender().getUid(),
      "user",
      message.getSender().getUid()
    ).then(
      () => {
        console.log("mark as read success.");
      },
      (error) => {
        console.log("An error occurred when marking the message as read.", error);
      }
    );
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    CometChat.markAsRead(
      message.getId(),
      message.getReceiverUid(),
      "group",
      message.getSender().getUid()
    ).then(
      () => {
        console.log("mark as read success.");
      },
      (error) => {
        console.log("An error occurred when marking the message as read.", error);
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_SENDER_UID";
    var receiverType: string = "user";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(
      () => {
        console.log("mark as read success.");
      },
      (error: CometChat.CometChatException) => {
        console.log("An error occurred when marking the message as read.", error);
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    var messageId: string = "MESSAGE_ID";
    var receiverId: string = "MESSAGE_RECEIVER_GUID";
    var receiverType: string = "group";
    var senderId: string = "MESSAGE_SENDER_UID";
    CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then(
      () => {
        console.log("mark as read success.");
      },
      (error: CometChat.CometChatException) => {
        console.log("An error occurred when marking the message as read.", error);
      }
    );
    ```
  </Tab>
</Tabs>

Another option the CometChat SDK provides is to pass the entire message object to the markAsRead() method.If the message object is the last message, the entire conversation will be marked as read.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.markAsRead(message);
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let message: CometChat.BaseMessage;
    CometChat.markAsRead(message);
    ```
  </Tab>
</Tabs>

In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.markAsRead(message).then(
      () => {
        console.log("mark as read success.");
      },
      (error) => {
        console.log("An error occurred when marking the message as read.", error);
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let message: CometChat.BaseMessage;
    CometChat.markAsRead(message).then(
      () => {
        console.log("mark as read success.");
      },
      (error: CometChat.CometChatException) => {
        console.log("An error occurred when marking the message as read.", error);
      }
    );
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `markAsRead()` returns a confirmation object:

  | Parameter   | Type   | Description                      | Sample Value |
  | ----------- | ------ | -------------------------------- | ------------ |
  | `messageId` | string | ID of the message marked as read | `"25323"`    |
  | `type`      | string | Message type                     | `"text"`     |
</Accordion>

## Mark Messages as Unread

The Mark as Unread feature allows users to designate specific messages or conversations as unread, even if they have been previously viewed.

This feature is valuable for users who want to revisit and respond to important messages or conversations later, ensuring they don't forget or overlook them.

In other words, how I can mark a message as unread?

You can mark the messages for a particular conversation as unread using the `markAsUnread()` method. This method takes the below parameters as input:

| Parameter | Information                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| message   | To mark a message as unread, pass a non-null `BaseMessage` instance to the `markMessageAsUnread()` function. All messages below that message in the conversation will contribute to the unread messages count. Example: When User B sends User A a total of 10 messages, and User A invokes the `markMessageAsUnread()` method on the fifth message, all messages located below the fifth message within the conversation list will be designated as unread. This results in a notification indicating there are 5 unread messages in the conversation list. |

<Note>
  You cannot mark your own messages as unread. This method only works for messages received from other users.
</Note>

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.markMessageAsUnread(message);
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let message: CometChat.BaseMessage;
    CometChat.markMessageAsUnread(message);
    ```
  </Tab>
</Tabs>

In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback).` On success, this method returns an updated `Conversation` object with the updated unread message count and other conversation data.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.markMessageAsUnread(message).then(
      (conversation) => {
        console.log("mark messages as unread success.", conversation);
        console.log("Unread message count:", conversation.getUnreadMessageCount());
      },
      (error) => {
        console.log("An error occurred when marking the message as unread.", error);
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let message: CometChat.BaseMessage;
    CometChat.markMessageAsUnread(message).then(
      (conversation: CometChat.Conversation) => {
        console.log("mark messages as unread success.", conversation);
        console.log("Unread message count:", conversation.getUnreadMessageCount());
      },
      (error: CometChat.CometChatException) => {
        console.log("An error occurred when marking the message as unread.", error);
      }
    );
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `markMessageAsUnread()` returns the updated `Conversation` object with the new unread count:

  <span id="mark-unread-conversation-object" style={{scrollMarginTop: '100px'}} />

  **Conversation Object:**

  | Parameter             | Type   | Description                            | Sample Value                                        |
  | --------------------- | ------ | -------------------------------------- | --------------------------------------------------- |
  | `conversationId`      | string | Unique conversation identifier         | `"cometchat-uid-6_user_cometchat-uid-7"`            |
  | `conversationType`    | string | Type of conversation                   | `"user"`                                            |
  | `unreadMessageCount`  | number | Number of unread messages              | `1`                                                 |
  | `unreadMentionsCount` | number | Number of unread mentions              | `0`                                                 |
  | `lastReadMessageId`   | string | ID of last read message                | `"25323"`                                           |
  | `latestMessageId`     | string | ID of latest message                   | `""`                                                |
  | `lastMessage`         | object | Last message in conversation           | [See below ↓](#mark-unread-lastmessage-object)      |
  | `conversationWith`    | object | User or group the conversation is with | [See below ↓](#mark-unread-conversationwith-object) |

  ***

  <span id="mark-unread-lastmessage-object" style={{scrollMarginTop: '100px'}} />

  **`lastMessage` Object:**

  | Parameter        | Type    | Description                       | Sample Value                                              |
  | ---------------- | ------- | --------------------------------- | --------------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25326"`                                                 |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-6_user_cometchat-uid-7"`                  |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-7"`                                       |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                                  |
  | `type`           | string  | Message type                      | `"text"`                                                  |
  | `category`       | string  | Message category                  | `"message"`                                               |
  | `text`           | string  | Message text content              | `"Hello <@uid:cometchat-uid-7>, this is a test mention!"` |
  | `sentAt`         | number  | Unix timestamp when sent          | `1772006074`                                              |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1772006158`                                              |
  | `readAt`         | number  | Unix timestamp when read          | `1772006158`                                              |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1772006158`                                              |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `true`                                                    |
  | `mentionedUsers` | array   | Users mentioned in message        | [See below ↓](#mark-unread-mentionedusers-array)          |
  | `sender`         | object  | Sender user details               | [See below ↓](#mark-unread-lastmessage-sender-object)     |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#mark-unread-lastmessage-receiver-object)   |
  | `reactions`      | array   | Message reactions                 | `[]`                                                      |

  ***

  <span id="mark-unread-mentionedusers-array" style={{scrollMarginTop: '100px'}} />

  **`lastMessage.mentionedUsers` Array (per item):**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-7"`                                                     |
  | `name`          | string  | User's display name                    | `"Henry Marino"`                                                        |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-7.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1772005334`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |

  ***

  <span id="mark-unread-lastmessage-sender-object" style={{scrollMarginTop: '100px'}} />

  **`lastMessage.sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-6"`                                                     |
  | `name`          | string  | User's display name                    | `"Ronald Jerry"`                                                        |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-6.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1772004288`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="mark-unread-lastmessage-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`lastMessage.receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-7"`                                                     |
  | `name`          | string  | User's display name                    | `"Henry Marino"`                                                        |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-7.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1772005334`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="mark-unread-conversationwith-object" style={{scrollMarginTop: '100px'}} />

  **`conversationWith` Object:**

  | Parameter        | Type    | Description                            | Sample Value                                                            |
  | ---------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`            | string  | User's unique identifier               | `"cometchat-uid-6"`                                                     |
  | `name`           | string  | User's display name                    | `"Ronald Jerry"`                                                        |
  | `avatar`         | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-6.webp"` |
  | `status`         | string  | User's online status                   | `"offline"`                                                             |
  | `role`           | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`   | number  | Last active timestamp                  | `1772004288`                                                            |
  | `hasBlockedMe`   | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`    | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt`  | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`           | array   | User tags                              | `[]`                                                                    |
  | `conversationId` | string  | Conversation identifier                | `"cometchat-uid-6_user_cometchat-uid-7"`                                |
</Accordion>

## Receive Delivery & Read Receipts

*In other words, as a recipient, how do I know when a message I sent has been delivered or read by someone?*

### Real-time events

1. `onMessagesDelivered()` - This event is triggered when a message is delivered to a user.
2. `onMessagesRead()` - This event is triggered when a message is read by a user.
3. `onMessagesDeliveredToAll()` - This event is triggered when a group message is delivered to all members of the group. This event is only for Group conversations.
4. `onMessagesReadByAll()` - This event is triggered when a group message is read by all members of the group. This event is only for Group conversations.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    let listenerId = "UNIQUE_LISTENER_ID";

    CometChat.addMessageListener(
      "listenerId",
      new CometChat.MessageListener({
        onMessagesDelivered: (messageReceipt) => {
          console.log("Message is delivered to a user: ", { messageReceipt });
        },
        onMessagesRead: (messageReceipt) => {
          console.log("Message is read by a user: ", { messageReceipt });
        },
        /** This event is only for Group Conversation. */
        onMessagesDeliveredToAll: (messageReceipt) => {
          console.log("Message delivered to all members of group: ", {
            messageReceipt,
          });
        },
        /** This event is only for Group Conversation. */
        onMessagesReadByAll: (messageReceipt) => {
          console.log("Message read by all members of group: ", { messageReceipt });
        },
      })
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let listenerId: string = "UNIQUE_LISTENER_ID";

    CometChat.addMessageListener(
      listenerId,
      new CometChat.MessageListener({
        onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => {
          console.log("Message is delivered to a user: ", { messageReceipt });
        },
        onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => {
          console.log("Message is read by a user: ", { messageReceipt });
        },
        /** This event is only for Group Conversation. */
        onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
          console.log("Message delivered to all members of group: ", {
            messageReceipt,
          });
        },
        /** This event is only for Group Conversation. */
        onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
          console.log("Message read by all members of group: ", { messageReceipt });
        },
      })
    );
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Event** — `onMessagesDelivered` returns a `MessageReceipt` object for user conversations:

  <span id="on-delivered-receipt-object" style={{scrollMarginTop: '100px'}} />

  **MessageReceipt Object (onMessagesDelivered):**

  | Parameter      | Type   | Description                    | Sample Value                               |
  | -------------- | ------ | ------------------------------ | ------------------------------------------ |
  | `receiptType`  | string | Type of receipt                | `"delivery"`                               |
  | `messageId`    | string | ID of the message              | `"25323"`                                  |
  | `receiverType` | string | Type of receiver               | `"user"`                                   |
  | `receiver`     | string | Receiver's UID                 | `"cometchat-uid-6"`                        |
  | `deliveredAt`  | number | Unix timestamp when delivered  | `1772005348`                               |
  | `timestamp`    | number | Event timestamp                | `1772005348`                               |
  | `sender`       | object | User who triggered the receipt | [See below ↓](#on-delivered-sender-object) |

  ***

  <span id="on-delivered-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object (onMessagesDelivered):**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-7"`                                                     |
  | `name`          | string  | User's display name                    | `"Henry Marino"`                                                        |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-7.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771853565`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  **On Event** — `onMessagesRead` returns a `MessageReceipt` object for user conversations:

  <span id="on-read-receipt-object" style={{scrollMarginTop: '100px'}} />

  **MessageReceipt Object (onMessagesRead):**

  | Parameter      | Type   | Description                    | Sample Value                          |
  | -------------- | ------ | ------------------------------ | ------------------------------------- |
  | `receiptType`  | string | Type of receipt                | `"read"`                              |
  | `messageId`    | string | ID of the message              | `"25323"`                             |
  | `receiverType` | string | Type of receiver               | `"user"`                              |
  | `receiver`     | string | Receiver's UID                 | `"cometchat-uid-6"`                   |
  | `readAt`       | number | Unix timestamp when read       | `1772005377`                          |
  | `timestamp`    | number | Event timestamp                | `1772005377`                          |
  | `sender`       | object | User who triggered the receipt | [See below ↓](#on-read-sender-object) |

  ***

  <span id="on-read-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object (onMessagesRead):**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-7"`                                                     |
  | `name`          | string  | User's display name                    | `"Henry Marino"`                                                        |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-7.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771853565`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  **On Event** — `onMessagesDeliveredToAll` returns a `MessageReceipt` object for group conversations (sender is System):

  <span id="on-delivered-all-receipt-object" style={{scrollMarginTop: '100px'}} />

  **MessageReceipt Object (onMessagesDeliveredToAll):**

  | Parameter      | Type   | Description                          | Sample Value                                   |
  | -------------- | ------ | ------------------------------------ | ---------------------------------------------- |
  | `receiptType`  | string | Type of receipt                      | `"deliveredToAll"`                             |
  | `messageId`    | string | ID of the message                    | `"25325"`                                      |
  | `receiverType` | string | Type of receiver                     | `"group"`                                      |
  | `receiver`     | string | Group GUID                           | `"tg1"`                                        |
  | `deliveredAt`  | number | Unix timestamp when delivered to all | `1772005516`                                   |
  | `timestamp`    | number | Event timestamp                      | `1772005516`                                   |
  | `sender`       | object | System user object                   | [See below ↓](#on-delivered-all-sender-object) |

  ***

  <span id="on-delivered-all-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object (onMessagesDeliveredToAll):**

  | Parameter       | Type    | Description                            | Sample Value   |
  | --------------- | ------- | -------------------------------------- | -------------- |
  | `uid`           | string  | System user identifier                 | `"app_system"` |
  | `name`          | string  | System user name                       | `"System"`     |
  | `role`          | string  | User's role                            | `"default"`    |
  | `status`        | string  | User's online status                   | `"offline"`    |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`        |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`        |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`            |

  ***

  **On Event** — `onMessagesReadByAll` returns a `MessageReceipt` object for group conversations (sender is System):

  <span id="on-read-all-receipt-object" style={{scrollMarginTop: '100px'}} />

  **MessageReceipt Object (onMessagesReadByAll):**

  | Parameter      | Type   | Description                     | Sample Value                              |
  | -------------- | ------ | ------------------------------- | ----------------------------------------- |
  | `receiptType`  | string | Type of receipt                 | `"readByAll"`                             |
  | `messageId`    | string | ID of the message               | `"25325"`                                 |
  | `receiverType` | string | Type of receiver                | `"group"`                                 |
  | `receiver`     | string | Group GUID                      | `"tg1"`                                   |
  | `readAt`       | number | Unix timestamp when read by all | `1772005546`                              |
  | `timestamp`    | number | Event timestamp                 | `1772005546`                              |
  | `sender`       | object | System user object              | [See below ↓](#on-read-all-sender-object) |

  ***

  <span id="on-read-all-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object (onMessagesReadByAll):**

  | Parameter       | Type    | Description                            | Sample Value   |
  | --------------- | ------- | -------------------------------------- | -------------- |
  | `uid`           | string  | System user identifier                 | `"app_system"` |
  | `name`          | string  | System user name                       | `"System"`     |
  | `role`          | string  | User's role                            | `"default"`    |
  | `status`        | string  | User's online status                   | `"offline"`    |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`        |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`        |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`            |
</Accordion>

<Warning>
  **Listener Cleanup Required** — Always remove your message listener when the component unmounts or the listener is no longer needed to avoid memory leaks and duplicate event handling:

  ```javascript theme={null}
  CometChat.removeMessageListener("UNIQUE_LISTENER_ID");
  ```

  In React Native, place this in a cleanup function inside `useEffect` or in `componentWillUnmount`.
</Warning>

You will receive events in the form of `MessageReceipt` objects. The message receipt contains the below parameters:

| Parameter      | Information                                                                                                                               |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `messageId`    | The Id of the message prior to which all the messages for that particular conversation have been marked as read.                          |
| `sender`       | User object containing the details of the user who has marked the message as read. System User for `deliveredToAll` & `readByAll` events. |
| `receiverId`   | Id of the receiver whose conversation has been marked as read.                                                                            |
| `receiverType` | type of the receiver (user/group)                                                                                                         |
| `receiptType`  | Type of the receipt (read/delivered)                                                                                                      |
| `deliveredAt`  | The timestamp of the time when the message was delivered. This will only be present if the receiptType is delivered.                      |
| `readAt`       | The timestamp of the time when the message was read. This will only be present when the receiptType is read.                              |

### Missed Receipts

You will receive message receipts when you load offline messages. While fetching messages in bulk, the message object will have two fields i.e. `deliveredAt` and `readAt` which hold the timestamp for the time the message was delivered and read respectively. Using these two variables, the delivery and read status for a message can be obtained.

However, for a group message, if you wish to fetch the `deliveredAt` and `readAt` fields of individual member of the group you can use the below-described method.

### Receipt History for a Single Message

To fetch the message receipts, you can use the `getMessageReceipts()` method.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    let messageId = msgId;
    CometChat.getMessageReceipts(messageId).then(
      (receipts) => {
        console.log("Message details fetched:", receipts);
      },
      (error) => {
        console.log("Error in getting messag details ", error);
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let messageId: number = 1;
    CometChat.getMessageReceipts(messageId).then(
      (receipts: CometChat.MessageReceipt[]) => {
        console.log("Message details fetched:", receipts);
      },
      (error: CometChat.CometChatException) => {
        console.log("Error in getting messag details ", error);
      }
    );
    ```
  </Tab>
</Tabs>

You will receive a list of `MessageReceipt` objects.

<Info>
  The following features will be available only if the **Enhanced Messaging Status** feature is enabled for your app.

  * `onMessagesDeliveredToAll` event,
  * `onMessagesReadByAll` event,
  * `deliveredAt` field in a group message,
  * `readAt` field in a group message.
  * `markMessageAsUnread` method.
</Info>

## Best Practices

<AccordionGroup>
  <Accordion title="When to mark messages as delivered vs. read">
    Mark messages as **delivered** as soon as they are received by the device — typically when fetching messages or receiving a real-time message while the app is open. Mark messages as **read** only when the user actually views the conversation or message. This distinction gives senders accurate insight into whether their message reached the device versus was actually seen.
  </Accordion>

  <Accordion title="Batch delivery receipts efficiently">
    Rather than calling `markAsDelivered()` for every individual message, pass the **last message** in a fetched list. The SDK marks all prior messages in that conversation as delivered automatically, reducing unnecessary API calls.
  </Accordion>

  <Accordion title="Always clean up message listeners">
    Remove message listeners when a component unmounts using `CometChat.removeMessageListener(listenerId)`. Failing to do so can cause memory leaks, duplicate callbacks, and unexpected behavior — especially in React Native navigation flows where screens may mount and unmount frequently.
  </Accordion>

  <Accordion title="Use the message object overload when possible">
    Prefer passing the full `BaseMessage` object to `markAsDelivered()` and `markAsRead()` instead of individual parameters. This is simpler, less error-prone, and ensures the SDK has all the context it needs.
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Receipts are not being received in real-time">
    Ensure you have registered a `MessageListener` with `CometChat.addMessageListener()` **before** the receipt events are dispatched. Verify the listener ID is unique and that you haven't accidentally removed the listener elsewhere. Also confirm the user is logged in and the WebSocket connection is active.
  </Accordion>

  <Accordion title="markAsRead or markAsDelivered calls are failing">
    Check that you are passing valid parameters — `messageId`, `receiverId`, `receiverType`, and `senderId` must all be correct. For group messages, `receiverId` should be the group GUID, not a user UID. Use the `.then()` error callback to inspect the `CometChatException` for details.
  </Accordion>

  <Accordion title="onMessagesDeliveredToAll or onMessagesReadByAll not firing">
    These events require the **Enhanced Messaging Status** feature to be enabled for your app in the [CometChat Dashboard](https://app.cometchat.com). Verify this setting is turned on if you rely on group-level delivery and read tracking.
  </Accordion>

  <Accordion title="markMessageAsUnread is not working">
    You cannot mark your own messages as unread — this method only works for messages received from other users. Additionally, the `markMessageAsUnread` method requires the **Enhanced Messaging Status** feature to be enabled.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Send a Message" icon="paper-plane" href="/sdk/react-native/send-message">
    Learn how to send text, media, and custom messages to users and groups.
  </Card>

  <Card title="Receive Messages" icon="inbox" href="/sdk/react-native/receive-messages">
    Set up real-time message listeners and fetch missed messages.
  </Card>

  <Card title="Retrieve Conversations" icon="comments" href="/sdk/react-native/retrieve-conversations">
    Fetch and display the user's conversation list with unread counts.
  </Card>

  <Card title="Typing Indicators" icon="keyboard" href="/sdk/react-native/typing-indicators">
    Show real-time typing status in one-on-one and group chats.
  </Card>
</CardGroup>
