Skip to content
Open
Show file tree
Hide file tree
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
132 changes: 112 additions & 20 deletions sdk/ios/delivery-read-receipts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,47 @@ 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`. |
| `onSuccess` | The callback listener that will be called on success. |
| `onError` | The callback listener that will be called on error. |

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

<Tabs>
<Tab title="Swift (User)">
```swift
CometChat.markConversationAsDelivered(conversationWithId: (conversation.conversationWith as? User)?.uid, receiverType: .user) { message in
print(message)
} onError: { error in
print(error.errorDescription)
}
```
</Tab>

<Tab title="Swift (Group)">
```swift
CometChat.markConversationAsDelivered(conversationWithId: (conversation.conversationWith as? Group)?.guid, receiverType: .group) { message in
print(message)
} onError: { error in
print(error.errorDescription)
}
```

</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 @@ -357,44 +398,95 @@ 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`. |
| `onSuccess` | The callback listener that will be called on success. |
| `onError` | The callback listener that will be called on error. |

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

<Tabs>
<Tab title="Swift (User)">
```swift
CometChat.markConversationAsRead(conversationWithId: (conversation.conversationWith as? User)?.uid, receiverType: .user) { message in
print(message)
} onError: { error in
print(error.errorDescription)
}
```

</Tab>

<Tab title="Swift (Group)">
```swift
CometChat.markConversationAsRead(conversationWithId: (conversation.conversationWith as? Group)?.guid, receiverType: .group) { message in
print(message)
} onError: { error in
print(error.errorDescription)
}
```

</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. 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:

| Field | Information |
| ------------------- | ----------------------------------------------- |
| conversationId | id of the conversation |
| conversationType | type of conversation (user/group) |
| lastMessage | last message in the conversation |
| conversationWith | User or Group object containing the details |
| unreadMessageCount | unread message count for the conversation |
| unreadMentionsCount | count of unread mentions in the conversation |
| lastReadMessageId | ID of the last read message in the conversation |
| 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(baseMessage: BaseMessage, receiverType: CometChat.ReceiverType, onSuccess: (Conversation) -> Void, onError: (CometChatException?) -> ())` 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. |
| onSuccess | The callback listener that will be called on success. |
| onError | The callback listener that will be called on error. |

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

<Tabs>
<Tab title="Swift">
<Tab title="Swift (User)">
```swift
let txt = TextMessage(receiverUid: "cometchat-uid-3", text: "this is unread count test", receiverType: .user)
txt.id = 3 // the message with id 3 will be marked unread. ID is required.
txt.sender = User(uid: "cometchat-uid-2", name: "George Alan")

CometChat.markAsUnread(baseMessage: txt) {
print("markAsUnread executed successfully: on message with ID: \(txt.id) and text \(txt.text)")
CometChat.markMessageAsUnread(baseMessage: message, receiverType: .user) { conversation in
print(conversation)
print(conversation.unreadMessageCount)
} onError: { error in
print("markAsUnread not executed error: \(error?.errorDescription)")
print(error?.errorDescription)
}
```

</Tab>
<Tab title="Swift (Group)">
```swift
CometChat.markMessageAsUnread(baseMessage: message, receiverType: .group) { conversation in
print(conversation)
print(conversation.unreadMessageCount)
} onError: { error in
print(error?.errorDescription)
}
```

</Tab>
</Tabs>

---

## 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?*
Expand Down
2 changes: 1 addition & 1 deletion sdk/ios/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ platform :ios, '12.0'
use_frameworks!

target 'YourApp' do
pod 'CometChatSDK', '4.0.72'
pod 'CometChatSDK', '4.0.73'
end
```

Expand Down
4 changes: 2 additions & 2 deletions sdk/ios/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ platform :ios, '11.0'
use_frameworks!

target 'MyApp' do
pod 'CometChatSDK', '4.0.72'
pod 'CometChatSDK', '4.0.73'
end
```

Expand Down Expand Up @@ -96,7 +96,7 @@ To install **Swift Packages** you can use Xcode package manager\*\*.\*\*
<img src="/images/fa786752-1634032671-f0fc1c00c9f33cca47875131228648cb.png" />
</Frame>

3. Once the pop-up appears, enter the github repository address in the search bar [`https://github.com/cometchat/chat-sdk-ios.git`](https://github.com/cometchat/chat-sdk-ios.git) and set dependency rule to `Up to Next Major Version` and set version as `4.0.72` . Then click on the **Add Package** button.
3. Once the pop-up appears, enter the github repository address in the search bar [`https://github.com/cometchat/chat-sdk-ios.git`](https://github.com/cometchat/chat-sdk-ios.git) and set dependency rule to `Up to Next Major Version` and set version as `4.0.73` . Then click on the **Add Package** button.

<Frame>
<img src="/images/edbea27b-nh6l7iltomtl4me5y6yzvupevalnh891fcoemppo30e6ijlc2boq1pxyanc6ujnt-438a8e2fee0f935ba81fc7ee14dc5ab7.png" />
Expand Down