Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

// Fetch conversations list
let request = ConversationRequest.ConversationRequestBuilder(limit: 30).build()
request.fetchNext(onSuccess: { conversations in }, onError: { error in })

// Get a specific conversation
CometChat.getConversation(conversationWith: "UID", conversationType: .user, onSuccess: { conv in }, onError: { error in })

// Tag a conversation
CometChat.tagConversation(conversationWith: "UID", conversationType: .user, tags: ["archived"], onSuccess: { conv in }, onError: { error in })

// Convert message to conversation
let conv = CometChat.getConversationFromMessage(message)
Conversations provide the last message for every one-on-one and group conversation the logged-in user is part of. Each Conversation object includes the other participant (user or group), the last message, unread counts, and optional tags. Use this to build a Recent Chats list.

Retrieve List of Conversations

Use ConversationsRequest with ConversationsRequestBuilder to fetch conversations with various filters.

Set Limit

Set the number of conversations to fetch per request. Maximum is 50.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 30).build()

Set Conversation Type

Filter by conversation type: .user for one-on-one or .group for group conversations. If not set, both types are returned.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .setConversationType(conversationType: .user)
  .build()

With User and Group Tags

Use withUserAndGroupTags(true) to include user/group tags in the response. Default is false.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .withUserAndGroupTags(true)
  .build()

Set User Tags

Fetch user conversations where the user has specific tags.
let limit = 30
let userTags = ["tag1"]
let conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: limit)
  .setUserTags(userTags)
  .build()

Set Group Tags

Fetch group conversations where the group has specific tags.
let limit = 30
let groupTags = ["tag1"]
let conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: limit)
  .setGroupTags(groupTags)
  .build()

With Tags

Use withTags(true) to include conversation tags in the response. Default is false.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .withTags(true)
  .build()

Set Tags

Fetch conversations that have specific tags.
let tags = ["pinned", "archived"]
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .setTags(tags)
  .build()

Include Blocked Users

var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .includeBlockedUsers(true)
  .build()

With Blocked Info

var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .withBlockedInfo(true)
  .build()

Search Conversations

Search conversations by user or group name.
Conversation & Advanced Search is available on Advanced and Custom plans. Enable it from the CometChat Dashboard under Chats → Settings → General Configuration.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .setSearchKeyword("Hiking")
  .build()

Unread Conversations

Conversation & Advanced Search is available on Advanced and Custom plans. Enable it from the CometChat Dashboard under Chats → Settings → General Configuration.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50)
  .setUnread(true)
  .build()

Fetch Conversations

After configuring the builder, call build() to create the request, then fetchNext() to retrieve conversations. Call fetchNext() repeatedly on the same object to paginate.
let convRequest = ConversationRequest.ConversationRequestBuilder(limit: 20)
  .setConversationType(conversationType: .user)
  .build()

convRequest.fetchNext(onSuccess: { (conversationList) in
  print("success of convRequest \(conversationList)")
}) { (exception) in
  print("here exception \(String(describing: exception?.errorDescription))")
}
The Conversation object consists of the following fields:
FieldInformation
conversationIdID of the conversation
conversationTypeType of conversation (user/group)
lastMessageLast message in the conversation
conversationWithUser or Group object containing the details
unreadMessageCountUnread message count for the conversation

Tag Conversation

Use tagConversation() to add tags to a conversation.
ParameterDescription
conversationWithUID or GUID of the user/group
conversationType.user or .group
tagsArray of tags to add
let id = "cometchat-uid-1"
let tags = ["pinned"]

CometChat.tagConversation(conversationWith: id, conversationType: .user, tags: tags, onSuccess: { conversation in
  print("conversation", conversation)
}, onError: { error in
  print("error", error)
})
Tags for conversations are one-way. If user A tags a conversation with user B, that tag applies only for user A.

Retrieve Single Conversation

Use getConversation() to fetch a specific conversation.
CometChat.getConversation(conversationWith: "cometchat-uid-3", conversationType: .user, onSuccess: { conversation in
  print("success \(String(describing: conversation?.stringValue()))")
}) { error in
  print("error \(String(describing: error?.errorDescription))")
}

Convert Messages to Conversations

Use getConversationFromMessage() to convert a received message into a Conversation object. Useful for updating your Recent Chats list when receiving real-time messages.
let myConversation = CometChat.getConversationFromMessage(message)
When converting a message to a conversation, unreadMessageCount and tags won’t be available. Manage unread counts in your client-side code.

Next Steps

Delete Conversation

Remove conversations from the logged-in user’s list

Receive Messages

Listen for incoming messages to update conversation lists in real time

Typing Indicators

Show real-time typing status in conversations

Delivery & Read Receipts

Track message delivery and read status per conversation