Skip to main content

Swift SDK (iOS)

The Orbit Swift SDK embeds Orbit’s end-user-facing surfaces into a native iOS app (also macOS, tvOS, and watchOS): in-app chat (the same omnichannel conversation/inbox the web widget uses), owned in-app messages and content cards, video rooms, and VoIP push registration for inbound-call delivery. It ships as four Swift Package Manager libraries — OrbitChat, OrbitInApp, OrbitVideoRoom, and OrbitPush — and targets iOS 13+. This is a client SDK: it authenticates only with a publishable key (dv_live_pk_…), because it ships inside a distributed app binary. It intentionally does not wrap the server-side management resources (messaging, voice, contacts, campaigns, verify) — those require a secret key and belong in your backend, via the Node SDK or the REST API. See Client / mobile SDKs (different scope, by design) on the SDK index.
Pre-publish — source-only. The Swift SDK is not yet in the Swift Package Index — the SPM install line below fails today. Until first publish, vendor the source from the monorepo (packages/sdk-swift/) and add the libraries as a local SPM package.

Installation (Swift Package Manager)

In Xcode: File ▸ Add Package Dependencies… and paste the same repository URL.

Headless chat client (OrbitChat)

The client ships zero UI — it owns the conversation lifecycle, history, optimistic send, and the real-time inbound stream; your UIKit or SwiftUI views render it.
Each on… method returns an OrbitSubscription; call .cancel() on it to stop receiving the event. Call chat.disconnect() to stop the real-time stream and retain the conversation id. Send a file attachment (10 MB client-side guard):

In-app messages and content cards (OrbitInApp)

Owned in-app surfaces — assembled server-side into a per-visitor feed, rendered locally, with impression / click / dismiss reported back.

Video rooms (OrbitVideoRoom)

Headless and engine-injected: your backend mints the room token server-side (POST /api/v1/video/rooms/:id/join) and hands the token plus server URL to the app. Wire the client over a VideoRoomEngine backed by a WebRTC engine (for example the Orbit Media SDK for Swift), so this package carries no hard WebRTC dependency.

Inbound-call VoIP push (OrbitPush)

A regular APNs alert token cannot reliably wake a force-quit app into the native CallKit incoming-call UI, so the backend keeps a dedicated VoIP device registry delivered on Apple’s PushKit (apns-push-type: voip) topic. OrbitPushClient hands the raw PushKit token to that registry without hand-rolled HTTP.

Error handling

API failures from any of the four libraries surface as typed errors carrying the HTTP status; construction misuse throws immediately.
Only the publishable key (dv_live_pk_… / dv_test_pk_…) may be embedded in the app. The clients refuse a server-side secret key (dv_live_sk_… / dv_test_sk_…) at construction — OrbitChatError.secretKeyRejected — because anything bundled in a distributed binary is extractable by any user. Real-time updates use header-authenticated polling (iOS has no SSE EventSource), so the key never lands in a URL log.