# Conversations & History > Start and continue conversations, list them, and page through their messages with the iOS SDK The SDK keeps track of the conversation you're in, and can list the user's past conversations and load their messages a page at a time. This page covers `newConversation`, `listConversations`, `listMessages` and the `Page` they return. ## Starting and continuing conversations **1. Send a message** The first `send` on a new client starts a new conversation. The server creates it. ```swift let response = try await client.send("Hello!") ``` **2. Keep the conversation ID if you need it** ```swift let conversationId = response.conversationId ``` The client also keeps it as `currentConversationId`. **3. Continue the conversation** The next `send` continues `currentConversationId` by itself. Pass an ID only to continue a different conversation: ```swift let followUp = try await client.send("Tell me more") let elsewhere = try await client.send("Any update?", conversationId: olderConversationId) ``` > [!WARNING] > > Passing `conversationId: nil` continues the client's current conversation, not a new one. To start fresh, call `newConversation()` first, or use a new [`ConversationState`](/docs/ios-sdk/swiftui), which always starts its own conversation. > > ```swift > // One conversation > try await client.send("My name is Alice.") > try await client.send("What is my name?") > > // Two conversations > try await client.send("My name is Alice.") > await client.newConversation() > try await client.send("What is my name?") > ``` ## newConversation ```swift public func newConversation() ``` Clears `currentConversationId`, so the next `send` starts a new conversation. ```swift await client.newConversation() try await client.send("Brand new conversation!") ``` > [!TIP] > > `identify(token:)` and `logout()` clear `currentConversationId` too, so a change of user never continues the previous user's conversation. ## listConversations ```swift public func listConversations( cursor: String? = nil, limit: Int = 20 ) async throws -> Page ``` Lists the signed-in user's conversations, or this device's while anonymous, most recently active first. | Parameter | Type | Required | Description | | - | - | - | - | | `cursor` | `String?` | No | The `cursor` from the previous page. Leave it out to start with the most recent conversations. | | `limit` | `Int` | No | How many per page, from 1 to 100. Defaults to 20. | ```swift let page = try await client.listConversations(limit: 20) for conversation in page.items { print("\(conversation.title ?? "New conversation")") print(" Status: \(conversation.status)") print(" Updated: \(conversation.updatedAt.formatted())") } print("Total: \(page.total)") print("Has more: \(page.hasMore)") ``` > [!NOTE] > > Only conversations created through the mobile SDKs are listed. Website chat, API and integration conversations are left out. Which ones you get depends on identity: the signed-in user's conversations if there is one, otherwise the device's. See [User Identity](/docs/ios-sdk/user-identity). See [`Conversation`](/docs/ios-sdk/conversation-models) for the full type. ## listMessages ```swift public func listMessages( conversationId: String, cursor: String? = nil, limit: Int = 20 ) async throws -> Page ``` Loads a page of a conversation's messages. | Parameter | Type | Required | Description | | - | - | - | - | | `conversationId` | `String` | Yes | The conversation to load. It must belong to the current user or device. | | `cursor` | `String?` | No | The `cursor` from the previous page. Leave it out to start with the latest messages. | | `limit` | `Int` | No | How many per page, from 1 to 100. Defaults to 20. | > [!NOTE] > > Pages go back in time. The first page holds the latest messages, and each later page holds older ones. Inside a page, messages run oldest to newest, so a page can go into a chat view as it is. When you load an older page, add it to the top. ```swift let page = try await client.listMessages(conversationId: conversationId, limit: 50) for message in page.items { let who = message.role == .user ? "You" : "Agent" print("\(who): \(message.text)") } ``` Each `Message` has a plain `text` (all its text parts joined) and a `parts` list, so you can show tool activity alongside the text: ```swift for part in message.parts { switch part { case .text(let text): renderBubble(text) case .toolCall(let call): renderToolCard(call.name, input: call.input) case .toolResult(let result): attachToolOutput(result.output) } } ``` Private notes your team adds in the Inbox are never returned. Replies a person sends after taking over the conversation come back with the role `.assistant`. See [`Message`](/docs/ios-sdk/chat-response) for the full type. ## Page ```swift public struct Page: 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?` | Pass it back to get the next page. `nil` on the last page. | | `hasMore` | `Bool` | Whether there are more pages. | | `total` | `Int` | How many items there are in all. | ### Loading the next page Pass `cursor` back with the same method to get the next page. Each page holds **only its own items**; add them to your own array, at the bottom for conversations or the top for older messages. ```swift 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) } print("Loaded \(all.count) of \(page.total)") ``` > [!TIP] > > [`ConversationListState`](/docs/ios-sdk/swiftui) and [`ConversationState`](/docs/ios-sdk/swiftui) keep the cursor and build up the list for you. Use them unless you need something custom. ### Infinite scroll in SwiftUI ```swift struct ConversationList: View { @State var list: ConversationListState var body: some View { List { ForEach(list.conversations) { conversation in ConversationRow(conversation) } if list.hasMore { ProgressView() .task { await list.loadMore() } } } .task { await list.load() } } } ``` ## Conversation status A conversation that has ended, or that a person has taken over, can't take new messages. Sending to one fails with `403` `CHAT_CONVERSATION_NOT_ONGOING`. Check the status before showing a text field: ```swift if conversation.status == .ongoing { showComposer() } else { showReadOnlyBanner() } ``` | Status | What it means | | - | - | | `.ongoing` | Open, and answered by your agent. | | `.ended` | Closed. Start a new conversation. | | `.takenOver` | A person on your team took it over from the Inbox. | ## Related > [card] Conversation & Pagination | /docs/ios-sdk/conversation-models | The full type reference. > [card] SwiftUI | /docs/ios-sdk/swiftui | Ready-made state for lists and history. > [card] Streaming | /docs/ios-sdk/streaming | Send messages and stream answers. > [card] User Identity | /docs/ios-sdk/user-identity | Tie conversations to users.