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
218 changes: 195 additions & 23 deletions sdk/android/delivery-read-receipts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,90 @@ Starting v3, the messages will not be marked delivered internally by the SDK. Yo

</Note>

## 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="Java (User)">
```java
CometChat.markConversationAsDelivered(user.getUid(), CometChatConstants.CONVERSATION_TYPE_USER, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
Log.i(TAG, "onSuccess: markConversationAsDelivered");
}

@Override
public void onError(CometChatException e) {
Log.i(TAG, "onError: markConversationAsDelivered");
}
});
```

</Tab>

<Tab title="Java (Group)">
```java
CometChat.markConversationAsDelivered(group.getGuid(), CometChatConstants.CONVERSATION_TYPE_GROUP, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
Log.i(TAG, "onSuccess: markConversationAsDelivered");
}

@Override
public void onError(CometChatException e) {
Log.i(TAG, "onError: markConversationAsDelivered");
}
});
```

</Tab>

<Tab title="Kotlin (User)">
```kotlin
CometChat.markConversationAsDelivered(
user.uid,
CometChatConstants.CONVERSATION_TYPE_USER,
object : CometChat.CallbackListener<String?>() {
override fun onSuccess(s: String?) {
Log.i(TAG, "onSuccess: markConversationAsDelivered")
}

override fun onError(e: CometChatException?) {
Log.i(TAG, "onError: markConversationAsDelivered")
}
})
```

</Tab>

<Tab title="Kotlin (Group)">
```kotlin
CometChat.markConversationAsDelivered(
group.guid,
CometChatConstants.CONVERSATION_TYPE_GROUP,
object : CometChat.CallbackListener<String?>() {
override fun onSuccess(s: String?) {
Log.i(TAG, "onSuccess: markConversationAsDelivered")
}

override fun onError(e: CometChatException?) {
Log.i(TAG, "onError: markConversationAsDelivered")
}
})
```

</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 @@ -374,35 +458,123 @@ Starting v3, the `markAsRead()` method working with v2.x is deprecated and will

</Note>

## 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="Java (User)">
```java
CometChat.markConversationAsRead(user.getUid(), CometChatConstants.CONVERSATION_TYPE_USER, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
Log.i(TAG, "onSuccess: markConversationAsRead");
}

@Override
public void onError(CometChatException e) {
Log.i(TAG, "onError: markConversationAsRead");
}
});
```

</Tab>

<Tab title="Java (Group)">
```java
CometChat.markConversationAsRead(group.getGuid(), CometChatConstants.CONVERSATION_TYPE_GROUP, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
Log.i(TAG, "onSuccess: markConversationAsRead");
}

@Override
public void onError(CometChatException e) {
Log.i(TAG, "onError: markConversationAsRead");
}
});
```

</Tab>

<Tab title="Kotlin (User)">
```kotlin
CometChat.markConversationAsRead(
user.uid,
CometChatConstants.CONVERSATION_TYPE_USER,
object : CometChat.CallbackListener<String?>() {
override fun onSuccess(s: String?) {
Log.i(TAG, "onSuccess: markConversationAsRead")
}

override fun onError(e: CometChatException?) {
Log.i(TAG, "onError: markConversationAsRead")
}
})
```

</Tab>

<Tab title="Kotlin (Group)">
```kotlin
CometChat.markConversationAsRead(
group.guid,
CometChatConstants.CONVERSATION_TYPE_GROUP,
object : CometChat.CallbackListener<String?>() {
override fun onSuccess(s: String?) {
Log.i(TAG, "onSuccess: markConversationAsRead")
}

override fun onError(e: CometChatException?) {
Log.i(TAG, "onError: markConversationAsRead")
}
})
```

</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 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:
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. |
| listener | The callback listener that will be called on success or error. This should be a non-null `CallbackListener` instance. |
| 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. |
| listener | The callback listener that will be called on success or error. This should be a non-null `CallbackListener` instance. |

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

<Tabs>
<Tab title="Java (User)">
```java
BaseMessage message = messageInstance;

CometChat.markAsUnread(message, new CometChat.CallbackListener<Void>() {
CometChat.markMessageAsUnread(message, new CometChat.CallbackListener<Conversation>() {
@Override
public void onSuccess(Void unused) {
Log.e("TAG", "markAsUnread: onSuccess");
public void onSuccess(Conversation conversation) {
Log.e("TAG", "markMessageAsUnread: onSuccess");
}

@Override
public void onError(CometChatException e) {
Log.e("TAG", "markAsUnread: onError: " + e);
Log.e("TAG", "markMessageAsUnread: onError: " + e);
}
});
```
Expand All @@ -413,13 +585,13 @@ CometChat.markAsUnread(message, new CometChat.CallbackListener<Void>() {
```kotlin
val message: BaseMessage = messageInstance

CometChat.markAsUnread(message, object : CometChat.CallbackListener<Void>() {
override fun onSuccess(unused: Void) {
Log.e("TAG", "markAsUnread: onSuccess")
CometChat.markMessageAsUnread(message, object : CometChat.CallbackListener<Conversation>() {
override fun onSuccess(conversation: Conversation) {
Log.e("TAG", "markMessageAsUnread: onSuccess")
}

override fun onError(e: CometChatException) {
Log.e("TAG", "markAsUnread: onError: $e")
Log.e("TAG", "markMessageAsUnread: onError: $e")
}
})
```
Expand All @@ -430,15 +602,15 @@ CometChat.markAsUnread(message, object : CometChat.CallbackListener<Void>() {
```java
BaseMessage message = messageInstance;

CometChat.markAsUnread(message, new CometChat.CallbackListener<Void>() {
CometChat.markMessageAsUnread(message, new CometChat.CallbackListener<Conversation>() {
@Override
public void onSuccess(Void unused) {
Log.e("TAG", "markAsUnread: onSuccess");
public void onSuccess(Conversation conversation) {
Log.e("TAG", "markMessageAsUnread: onSuccess");
}

@Override
public void onError(CometChatException e) {
Log.e("TAG", "markAsUnread: onError: " + e);
Log.e("TAG", "markMessageAsUnread: onError: " + e);
}
});
```
Expand All @@ -449,13 +621,13 @@ CometChat.markAsUnread(message, new CometChat.CallbackListener<Void>() {
```kotlin
val message: BaseMessage = messageInstance

CometChat.markAsUnread(message, object : CometChat.CallbackListener<Void>() {
override fun onSuccess(unused: Void) {
Log.e("TAG", "markAsUnread: onSuccess")
CometChat.markMessageAsUnread(message, object : CometChat.CallbackListener<Conversation>() {
override fun onSuccess(conversation: Conversation) {
Log.e("TAG", "markMessageAsUnread: onSuccess")
}

override fun onError(e: CometChatException) {
Log.e("TAG", "markAsUnread: onError: $e")
Log.e("TAG", "markMessageAsUnread: onError: $e")
}
})
```
Expand Down Expand Up @@ -599,6 +771,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>