iOS SDK
The iOS SDK is a native Swift library that embeds PolyAI’s messaging agent directly inside your iOS app. It’s headless by design — you own the UI, PolyAI provides the AI layer underneath. Your app connects to the same agent logic used across voice, webchat, and other channels.
The iOS SDK wraps the Messaging API. All WebSocket events, streaming, and handoff behavior documented in the API reference apply.
How it works
The SDK handles authentication, session management, WebSocket connections, and reconnection logic. Your app sends and receives messages through the SDK and renders them however you choose.
Configure authentication
Add your API key (from Agent Studio) and register your app’s bundle identifier in Agent Studio. The backend rejects connections from unregistered bundle identifiers.
Installation
The SDK is distributed as a native Swift package. Choose either method:
Swift Package Manager
CocoaPods
In Xcode, go to File > Add Package Dependencies and enter the repository URL:
Select the latest version and add the package to your target.
Authentication setup
The iOS SDK authenticates using a connector token and your app’s bundle identifier.
Never embed the connector token directly in your app binary. Use a backend service to mint short-lived access tokens and pass them to the SDK. See security best practices.
Key features
Session persistence
Sessions persist across app launches. If the user leaves and returns, the SDK reconnects to the existing session and replays the conversation history automatically. Network changes (Wi-Fi to cellular, brief drops) are handled with automatic reconnection and retry.
Streaming responses
Enable streaming when creating a session to show agent responses as they’re generated, word by word. The SDK surfaces streaming chunks as they arrive — your UI can render them incrementally.
Handoff to live agents
The full handoff flow is supported. When the PolyAI agent triggers a handoff, the SDK delivers the same handoff events (HANDOFF_ACCEPTED, HANDOFF_QUEUE_STATUS, LIVE_AGENT_JOINED, etc.) so your app can show queue status and live agent messages.
Response suggestions
Agent messages can include response_suggestions — pre-written reply options. Render these as tappable buttons in your UI. When the user taps one, send its text as a message through the SDK.
Attachments
Agent messages may include rich content like links and images via the attachments field. Render these inline in your chat UI.
Platform values
When the SDK creates a session, it sets platform to ios automatically. This is visible in Agent Studio analytics and can be used in your agent logic to tailor behavior for mobile users.
Limitations
These limitations apply to the initial release. Check the release notes for updates.
Multichannel
The iOS SDK connects to the same agent project as your voice and webchat channels. Agent behavior, knowledge, and flows are shared — only channel-specific settings (greetings, formatting) differ. See multichannel agents for how to tailor behavior per channel.
In your agent’s start function, detect the mobile channel using conv.channel_type:

