Cartesiandocs

iOS

API reference

The public types of CartesianCore and CartesianUI.

CartesianCore

CartesianConfig

CartesianConfig(
    vertical: Vertical,            // .grocery or .apparel
    baseURL: URL,                  // your backend; REST at <baseURL>/api, WebSocket at <baseURL>/ws
    urlSession: URLSession? = nil, // your own session (cookies are never handled by URLSession)
    userAgent: String? = nil,      // appended to "cartesian-ios/<version>"
    logger: CartesianLogger? = nil,
    licenseKey: String? = nil
)
swift

Every request sends X-Cartesian-SDK: ios/<version>.

CartesianClient

@MainActor final class, ObservableObject.

authStateAuthState
.restoring, .signedOut or .signedIn(User). Published.
connectionConnectionState
.idle, .connecting, .open, .closed. Published.
cartCart
Lines, itemCount, total, currency, quantity(of:). Published.
wishlistWishlist
products, contains(_:). Published.
threads[ThreadSummary]
Past chats. Published.
chatChatSession
The conversation.
hasSavedSessionBool
A token is stored.

Methods: signIn(sessionToken:), restore(), signOut(), connect(), disconnect(), refreshThreads(), renameThread(_:name:), deleteThread(_:), refreshCart(), addToCart(_:quantity:), setCartQuantity(_:quantity:), removeFromCart(_:), clearCart(), refreshWishlist(), save(_:), unsave(_:), profile(), compare(_:), readPhotoText(jpegDataURL:).

ChatSession

@MainActor final class, ObservableObject. Published state: ChatState and suggestions: [String]; threadId; events() -> AsyncStream<ChatEvent>; eventPublisher; send(_:), stop(), newChat(), open(_:), retry(), rate(_:_:), dismissError().

Models

TypeNotes
ProductWraps the backend JSON. id, name, brand, imageURL, price (sale price when lower), regularPrice, isOnSale, size, aisle, isSnapEligible, promoLabel, isUsual, subscript(attribute), json, toJSON(), fromJSON(_:), make(id:name:)
ChatMessage.user(UserMessage) or .assistant(AssistantMessage)
AgentStepid, title, detail, phase (.started, .completed, .failed), kind (.search, .tool, .system), tool, cached
CartUpdateoperation, changedCount, itemCount, total, currency
Comparisonproducts, rows, summary, nextStep, recommendations, prosCons
ShopperProfilename, facts, members
ChatEvent.turnStarted, .turnFinished, .productsShown, .cartChanged, .error
CartesianErrorSee Headless

SessionStore

public protocol SessionStore: AnyObject, Sendable {
    func load(key: String) -> String?
    func save(key: String, token: String)
    func clear(key: String)
}
swift

KeychainSessionStore(service:accessGroup:) (default, AfterFirstUnlockThisDeviceOnly) and InMemorySessionStore() are included.

CartesianLicense

CartesianLicense.verify(_ token:, appId:, now:) returns partner, whiteLabel, expiresAt, problem and isValid.

CartesianUI

Cartesian

Member
configure(_:options:sessionStore:)Create the shared client. Calling it again with the same vertical and URL returns the existing client.
clientThe shared CartesianClient
options / update(options:)The default options for every view
delegateweak var CartesianDelegate?
hostCartesianHostState: setCart([String: Int]), setSaved(Set<String>)
present(from:prompt:animated:)UIKit sheet

CartesianDelegate

@MainActor protocol; every method has a default implementation.

func onAddToCart(_ product: Product, quantity: Int)
func onOpenCart()
func onToggleSaved(_ product: Product, saved: Bool)
func onOpenWishlist()
func onProductSelected(_ product: Product)
func onCheckout(_ cart: Cart) -> Bool      // return true when your app handled checkout
func onEvent(_ event: ChatEvent)
func onSignInRequired()                    // signed out while online
swift

CartesianChatController

The state and actions every component works from. CartesianChatView(controller:) lets you create and keep your own.

StateActions
chat, connection, auth, cart, wishlistsend(_:), stop(), newChat(), retry(), rate(_:_:)
draft (read/write), drawer, error, isRetryingaddToCart(_:quantity:), setQuantity(_:_:), toggleSaved(_:)
suggestions, starters, canSend, isDeviceOnlineopenProduct(_:), openCart(), openWishlist(), showDrawer(_:), checkout()
cartCount, savedCount, quantityInCart(_:), isSaved(_:), isBusy(_:)saveForLater(_:), moveToCart(_:), dismissError(), retryConnection()
features, vertical, assistantName, cartName, isWhiteLabel, license

Views

View
CartesianChatView(client:options:delegate:onClose:)The chat screen
.cartesianPanel(_:layout:client:options:delegate:onHidden:)Adaptive panel driven by CartesianPanelState
.cartesianPanel(isPresented:prompt:layout:…)The same, bound to a Bool
CartesianPanelHost(_:layout:…) { content }Container form of the panel
CartesianAskButton(state:visible:expanded:label:icon:prompt:containerColor:contentColor:options:)Floating trigger
CartesianAskBar(state:placeholder:options:)Search-style trigger
CartesianComponents.*The default building blocks; see Customize

PanelLayout: .auto, .bottomSheet, .sidePanel, .floating, .fullScreen. SheetDetent: .hidden, .half, .full.

Accessibility and offline

  • Every control has a VoiceOver label; status changes (offline, reconnecting, errors) are announced.
  • Text follows Dynamic Type up to accessibility size 2. The orb stops animating when Reduce Motion is on.
  • NWPathMonitor drives the offline pill, the offline banner during a chat and the offline screen with Try again.