Prerequisites
Before starting, make sure you have:- Installed the SDK
- Access to a LiveKit server URL (e.g.,
wss://your-server.livekit.cloud) - A valid LiveKit token (generate one from your LiveKit dashboard)
If you don’t have a LiveKit server yet, you can create a free account at LiveKit Cloud to get started.
Create a Room View Controller
Here’s a complete example that connects to a room, publishes your camera and microphone, and displays both local and remote video:Step-by-Step Breakdown
Let’s break down what’s happening in this example:Create the Room
Room object is your main interface to LiveKit. It manages the connection, participants, and tracks.Set up Video Views
VideoView is a UIKit component that renders video tracks. You need one view for each video stream you want to display.Connect to the Room
Publish Camera and Microphone
Important Notes
Audio Playback: Subscribed audio tracks are played automatically. You don’t need to do anything special to hear remote participants.
Auto-Subscribe: By default, the SDK automatically subscribes to all published tracks from remote participants. You can disable this with
ConnectOptions(autoSubscribe: false).Running Your App
-
Add permissions to your
Info.plist: - Get your server URL and token from the LiveKit dashboard
- Run your app and test it with another client (web, iOS, or Android)
Next Steps
Core Concepts
Learn about rooms, participants, and tracks
Camera & Microphone
Configure camera and audio capture options
Screen Sharing
Add screen sharing to your app
API Reference
Explore the complete API
Troubleshooting
Connection fails with invalid token
Connection fails with invalid token
Make sure your token is valid and not expired. Tokens are JWTs that contain room name, participant identity, and expiration time. Generate a new token from your LiveKit dashboard.
Camera/microphone permissions denied
Camera/microphone permissions denied
Check that you’ve added the required
NSCameraUsageDescription and NSMicrophoneUsageDescription keys to your Info.plist. If the user denied permissions, you’ll need to ask them to grant them in Settings.Remote video not showing
Remote video not showing
Make sure:
- The remote participant is publishing video
- You’ve implemented the
didSubscribeTrackdelegate method - You’re assigning the track to a VideoView on the main thread
- The VideoView is added to your view hierarchy and visible
Audio not working
Audio not working
Audio tracks are played automatically, but make sure:
- The device volume is not muted
- Your app hasn’t disabled audio playback via
AudioManager - The remote participant is publishing an audio track