Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
// Fetch conversations listlet request = ConversationRequest.ConversationRequestBuilder(limit: 30).build()request.fetchNext(onSuccess: { conversations in }, onError: { error in })// Get a specific conversationCometChat.getConversation(conversationWith: "UID", conversationType: .user, onSuccess: { conv in }, onError: { error in })// Tag a conversationCometChat.tagConversation(conversationWith: "UID", conversationType: .user, tags: ["archived"], onSuccess: { conv in }, onError: { error in })// Convert message to conversationlet 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.
Conversation & Advanced Search is available on Advanced and Customplans. Enable it from the CometChat Dashboard under Chats → Settings → General Configuration.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50) .setSearchKeyword("Hiking") .build()
Conversation & Advanced Search is available on Advanced and Customplans. Enable it from the CometChat Dashboard under Chats → Settings → General Configuration.
var conversationRequest = ConversationRequest.ConversationRequestBuilder(limit: 50) .setUnread(true) .build()
After configuring the builder, call build() to create the request, then fetchNext() to retrieve conversations. Call fetchNext() repeatedly on the same object to paginate.
Swift (User)
Swift (Group)
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))")}
let convRequest = ConversationRequest.ConversationRequestBuilder(limit: 20) .setConversationType(conversationType: .group) .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:
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.