Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 125 additions & 30 deletions sdk/flutter/delivery-read-receipts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,52 @@ debugPrint("markAsDelivered unsuccessful : ${e.message} ");

</Tabs>

## Mark Conversation as Delivered

You can mark an entire conversation as delivered for a user or group using the `markConversationAsDelivered()` method. This method takes the below parameters as input:

| Parameter | Information |
| ------------------ | ------------------------------------------------------------------------------ |
| `conversationWith` | The ID of the user (UID) or group (GUID) for the conversation. |
| `conversationType` | Type of the conversation. Could be either `user` or `group`. |

This method will mark all messages in the conversation as delivered.

<Tabs>
<Tab title="Dart (User)">
```dart
CometChat.markConversationAsDelivered(
user.uid,
CometChatConversationType.user,
onSuccess: (String s) {
debugPrint("markConversationAsDelivered: onSuccess");
},
onError: (CometChatException e) {
debugPrint("markConversationAsDelivered: onError: ${e.message}");
},
);
```

</Tab>

<Tab title="Dart (Group)">
```dart
CometChat.markConversationAsDelivered(
group.guid,
CometChatConversationType.group,
onSuccess: (String s) {
debugPrint("markConversationAsDelivered: onSuccess");
},
onError: (CometChatException e) {
debugPrint("markConversationAsDelivered: onError: ${e.message}");
},
);
```

</Tab>

</Tabs>

## Mark Messages as Read

*In other words, as a recipient, how do I inform the sender I've read a message?*
Expand Down Expand Up @@ -95,32 +141,83 @@ CometChat.markAsRead(message, onSuccess: (String unused) {

</Tabs>

## Mark Conversation as Read

You can mark an entire conversation as read for a user or group using the `markConversationAsRead()` method. This method takes the below parameters as input:

| Parameter | Information |
| ------------------ | ------------------------------------------------------------------------------ |
| `conversationWith` | The ID of the user (UID) or group (GUID) for the conversation. |
| `conversationType` | Type of the conversation. Could be either `user` or `group`. |

This method will mark all messages in the conversation as read.

<Tabs>
<Tab title="Dart (User)">
```dart
CometChat.markConversationAsRead(
user.uid,
CometChatConversationType.user,
onSuccess: (String s) {
debugPrint("markConversationAsRead: onSuccess");
},
onError: (CometChatException e) {
debugPrint("markConversationAsRead: onError: ${e.message}");
},
);
```

</Tab>

<Tab title="Dart (Group)">
```dart
CometChat.markConversationAsRead(
group.guid,
CometChatConversationType.group,
onSuccess: (String s) {
debugPrint("markConversationAsRead: onSuccess");
},
onError: (CometChatException e) {
debugPrint("markConversationAsRead: onError: ${e.message}");
},
);
```

</Tab>

</Tabs>

## 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.
The Mark message 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 message as unread?*
*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.
You can mark the messages for a particular conversation as unread using the `markMessageAsUnread()` 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 `markAsUnread()` 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 `markAsUnread()` 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. |
| 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="Dart">
```dart
CometChat.markAsUnread(
message,
onSuccess: (success) {
debugPrint("markAsUnread : $success");
},
onError: (error) {
debugPrint("markAsUnread unsuccessfull : $error");
},
);
CometChat.markMessageAsUnread(
message,
onSuccess: (Conversation conversation) {
debugPrint("markMessageAsUnread: onSuccess");
},
onError: (CometChatException e) {
debugPrint("markMessageAsUnread: onError: ${e.message}");
},
);
```

</Tab>
Expand Down Expand Up @@ -196,26 +293,24 @@ In order to fetch the message receipts, you can use the `getMessageReceipts()` m
<Tabs>
<Tab title="Dart">
```dart
private int messageId = 10101;

CometChat.getMessageReceipts(messageId, new CometChat.CallbackListener<List<MessageReceipt>>() {
@Override
public void onSuccess(List<MessageReceipt> messageReceipts) {
// Handle message receipts
}

@Override
public void onError(CometChatException e) {
// Handle error
}
});
int messageId = 10101;

CometChat.getMessageReceipts(
messageId,
onSuccess: (List<MessageReceipt> messageReceipts) {
// Handle message receipts
},
onError: (CometChatException e) {
// Handle error
},
);
```

</Tab>

</Tabs>

You will receive a list of `MessageReceipt` objects in the `onSuccess()` method.
You will receive a list of `MessageReceipt` objects in the `onSuccess()` callback.

<Info>

Expand All @@ -225,6 +320,6 @@ The following features will be available only if the **Enhanced Messaging Status
* `onMessagesReadByAll` event,
* `deliveredAt` field in a group message,
* `readAt` field in a group message.
* `markAsUnread` method.
* `markMessageAsUnread` method.

</Info>