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)
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.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.reportEvent takes the InAppEventType enum (.impression / .click /
.dismiss) — the closed set the server accepts, plus the per-language fix for
the 422 a raw string or alias earns, is in
InAppEventType: the in-app event enum.
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.
Backend: register tokens with the API
The Swift client wraps token onboarding for you; when your backend needs to register or refresh a device itself — a bulk import on migration, an upsert after sign-in — it makes a secret-key call in the language your backend already speaks. There are two registries, and the token type picks the route:- Regular APNs alert tokens (in-app messages, content updates) →
POST /api/v1/push/device-tokenswithplatform: 'ios'and the APNs device token. - PushKit VoIP tokens (the inbound-call flow above) →
POST /api/v1/push/voip-deviceswithplatform: 'ios', the PushKit token asvoip_token, andbundle_id— the APNsapns-topicfor a VoIP push is<bundle_id>.voip, so the registry keeps it per device.
/push/device-tokens wraps the stored row in the standard
envelope — data.id is the handle for the sign-out delete:
201 Created (device-tokens)
/push/voip-devices answers 201 with the same envelope and a
VoIP-shaped row — data.id, platform, voip_token, and bundle_id.
Re-registering an existing token is an upsert on either route — it bumps
last_seen (and un-revokes a VoIP row the delivery side marked dead)
instead of creating a duplicate, and the 201 returns the row’s original
id. On sign-out, unregister so the device stops ringing:
Unregister on sign-out (204)
?token=<raw-apns-token> (or ?voip_token=<raw-pushkit-token> on the VoIP
route) to the same DELETE and the route falls back to matching the raw
token.
To exercise the flow without touching real devices, use a key minted on
your sandbox organization (dv_test_sk_…); dashboard sessions add
X-Test-Mode: true via the console’s Test/Live toggle. See
Sandbox API samples.
This is the only section on this page that takes a secret key — every
client library above authenticates with the publishable key and refuses a
secret at construction, because anything bundled in a distributed binary
is extractable. Delivery-side mechanics (categories, rich media,
scheduling) live in the push channel reference.
Runnable examples
The package’sexamples/ directory holds self-contained end-to-end files — each takes the publishable key from ORBIT_PUBLIC_KEY (dv_test_pk_… / dv_live_pk_…): ChatConnectSend (chat connect + send with OrbitAPIError.status handling), InAppFeed (/sdk/in-app/feed fetch + impression + dismiss), and PushKitTokenRefresh (VoIP token rollover via /push/voip-devices, plus sign-out unregister(deviceId:)). Swap sandbox vs live by changing the env value — no code edits. See packages/sdk-swift/examples/README.md for how to compile them as an SPM executable target.
Error handling
API failures from any of the four libraries surface as typed errors carrying the HTTP status; construction misuse throws immediately.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.