iOS SDK
Conversation & Pagination
Reference for Conversation, Conversation.Status and Page, the types used for conversation history
listConversations returns Conversation values, and both list methods wrap their results in a Page. This page lists every field.
Conversation
struct Conversation: Sendable, Equatable, Identifiable, Decodable
What listConversations returns.
public struct Conversation: Sendable, Equatable, Identifiable, Decodable {
public enum Status: String, Sendable, Codable { case ongoing, ended, takenOver = "taken_over" }
public let id: String
public let title: String?
public let createdAt: Date
public let updatedAt: Date
public let userId: String?
public let status: Status
}| Property | Type | Description |
|---|---|---|
id | String | The conversation ID. Pass it to listMessages or send. |
title | String? | A short summary QwryAI writes for the conversation. nil until there is one, so show something like "New conversation" instead. |
createdAt | Date | When the conversation started. |
updatedAt | Date | When it was last active. Lists come sorted on this, newest first. |
userId | String? | The signed-in user the conversation belongs to, or nil if it belongs to a device. |
status | Status | See Conversation.Status. |
Conversation is Identifiable, so it works with ForEach and List as it is:
List(conversations) { conversation in
NavigationLink {
ChatScreen(client: client, conversationId: conversation.id)
} label: {
VStack(alignment: .leading) {
Text(conversation.title ?? "New conversation")
Text(conversation.updatedAt, style: .relative)
.font(.caption)
.foregroundStyle(.secondary)
}
}
}Conversation.Status
public enum Status: String, Sendable, Codable {
case ongoing // "ongoing" open, answered by your agent
case ended // "ended" closed
case takenOver = "taken_over" // a person on your team took over
}Only .ongoing conversations take new messages. Sending to any other fails with 403 CHAT_CONVERSATION_NOT_ONGOING. See Error Handling.
if conversation.status == .ongoing {
showComposer()
} else {
showReadOnlyBanner()
}Message
Message is used for both answers and history. See ChatResponse for the full reference, along with MessagePart, Message.Role and Message.Feedback.
Page
struct Page<Item: Sendable & Decodable>: Sendable, Decodable
What listConversations() and listMessages(conversationId:) return.
public struct Page<Item: Sendable & Decodable>: Sendable, Decodable {
public let items: [Item]
public let cursor: String?
public let hasMore: Bool
public let total: Int
}| Property | Type | Description |
|---|---|---|
items | [Item] | The items on this page. |
cursor | String? | Where the next page starts. Pass it back as cursor. nil on the last page. |
hasMore | Bool | Whether there are more pages. |
total | Int | How many items there are in all. |
Next page
There's no helper on the page itself: pass cursor back to the same method. Keep the same limit so pages stay the same size.
var page = try await client.listConversations(limit: 20)
var all = page.items
while page.hasMore, let cursor = page.cursor {
page = try await client.listConversations(cursor: cursor, limit: 20)
all.append(contentsOf: page.items)
}