AVAudioSession integration. The underlying WebRTC protocol is described in the
WebRTC connection guide — this page covers the iOS-specific
implementation.
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 — Swift Package Manager dialog
Screenshot — Swift Package Manager dialog
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 This key is required for voice sessions. The app will crash on launch without it.
Info.plist (or your target’s Info tab in Xcode) and add:Text and streaming
- Text session
- 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)
Pause the voice session when a call or alarm interrupts
Pause the voice session when a call or alarm interrupts
Observe
AVAudioSession.interruptionNotification and pause/resume the session accordingly.Handling route changes (headphones)
Respond to audio route changes — headphone plug/unplug
Respond to audio route changes — headphone plug/unplug
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
Keep voice sessions alive in the background
Keep voice sessions alive in the background
By default, iOS suspends apps after they move to the background. To keep a voice session
running while the user is on another screen:With this capability, the
- In Xcode, open your target’s Signing & Capabilities tab.
- Click + Capability and add Background Modes.
- Check Audio, AirPlay, and Picture in Picture.
Info.plist:AVAudioSession remains active while the app is in the background
and the voice session continues uninterrupted.