Skip to main content
The iOS SDK provides native Swift async/await APIs for text sessions and a full WebRTC voice pipeline with AVAudioSession integration. The underlying WebRTC protocol is described in the WebRTC connection guide — this page covers the iOS-specific implementation.
During development, initialise the client with an hk_test_… sandbox credential instead of hk_live_…. There is no separate sandbox mode or URL — sandbox behavior comes entirely from the credential prefix. No AI credits are consumed and no usage is billed. See Sandbox mode.

Install

1

Add the Swift package

In Xcode, open your project and select File → Add Package Dependencies.Enter the repository URL:
Select Up to Next Major Version from 1.0.0 and click Add Package.
Screenshot: Xcode → File → Add Package Dependencies → kiosk-swift
2

Add the package to your target

In the package selection dialog, check the box next to your app target, then click Add Package.
3

Add the microphone usage description

Open Info.plist (or your target’s Info tab in Xcode) and add:
This key is required for voice sessions. The app will crash on launch without it.

Text and streaming

Each openSession() call creates an independent conversation on the server. Use defer to ensure the session is always closed.

Voice session

The SDK requests microphone permission automatically on the first openVoiceSession() call. The NSMicrophoneUsageDescription key in Info.plist must be set or the app will crash before showing the permission prompt.

Handling interruptions (phone calls)

Observe AVAudioSession.interruptionNotification and pause/resume the session accordingly.

Handling route changes (headphones)

When the user unplugs headphones, iOS routes audio to the speaker, which can cause echo. Pause the session briefly while the route stabilises.

Background audio

By default, iOS suspends apps after they move to the background. To keep a voice session running while the user is on another screen:
  1. In Xcode, open your target’s Signing & Capabilities tab.
  2. Click + Capability and add Background Modes.
  3. Check Audio, AirPlay, and Picture in Picture.
This adds the following to your Info.plist:
With this capability, the AVAudioSession remains active while the app is in the background and the voice session continues uninterrupted.
Apple’s App Store review guidelines require that background audio has a genuine user benefit. Voice assistant apps qualify — background music players in disguise do not.

Never hard-code your credential. Read it from an environment variable: