diff --git a/sdk/flutter/delivery-read-receipts.mdx b/sdk/flutter/delivery-read-receipts.mdx index 1d1716d1..19a315a8 100644 --- a/sdk/flutter/delivery-read-receipts.mdx +++ b/sdk/flutter/delivery-read-receipts.mdx @@ -41,6 +41,52 @@ debugPrint("markAsDelivered unsuccessful : ${e.message} "); +## 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. + + + +```dart +CometChat.markConversationAsDelivered( + user.uid, + CometChatConversationType.user, + onSuccess: (String s) { + debugPrint("markConversationAsDelivered: onSuccess"); + }, + onError: (CometChatException e) { + debugPrint("markConversationAsDelivered: onError: ${e.message}"); + }, +); +``` + + + + +```dart +CometChat.markConversationAsDelivered( + group.guid, + CometChatConversationType.group, + onSuccess: (String s) { + debugPrint("markConversationAsDelivered: onSuccess"); + }, + onError: (CometChatException e) { + debugPrint("markConversationAsDelivered: onError: ${e.message}"); + }, +); +``` + + + + + ## Mark Messages as Read *In other words, as a recipient, how do I inform the sender I've read a message?* @@ -95,32 +141,83 @@ CometChat.markAsRead(message, onSuccess: (String unused) { +## 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. + + + +```dart +CometChat.markConversationAsRead( + user.uid, + CometChatConversationType.user, + onSuccess: (String s) { + debugPrint("markConversationAsRead: onSuccess"); + }, + onError: (CometChatException e) { + debugPrint("markConversationAsRead: onError: ${e.message}"); + }, +); +``` + + + + +```dart +CometChat.markConversationAsRead( + group.guid, + CometChatConversationType.group, + onSuccess: (String s) { + debugPrint("markConversationAsRead: onSuccess"); + }, + onError: (CometChatException e) { + debugPrint("markConversationAsRead: onError: ${e.message}"); + }, +); +``` + + + + + ## 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. | + + +You cannot mark your own messages as unread. This method only works for messages received from other users. + + ```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}"); + }, +); ``` @@ -196,26 +293,24 @@ In order to fetch the message receipts, you can use the `getMessageReceipts()` m ```dart -private int messageId = 10101; - -CometChat.getMessageReceipts(messageId, new CometChat.CallbackListener>() { -@Override - public void onSuccess(List messageReceipts) { - // Handle message receipts -} - -@Override - public void onError(CometChatException e) { - // Handle error -} -}); +int messageId = 10101; + +CometChat.getMessageReceipts( + messageId, + onSuccess: (List messageReceipts) { + // Handle message receipts + }, + onError: (CometChatException e) { + // Handle error + }, +); ``` -You will receive a list of `MessageReceipt` objects in the `onSuccess()` method. +You will receive a list of `MessageReceipt` objects in the `onSuccess()` callback. @@ -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.