Quick Start
Connect the Vio SDK to your streaming app in under 10 minutes.
1. Add the Package
In Xcode: File → Add Package Dependencies…
https://github.com/vio-live/VioSwiftSDK.gitSelect version 0.2.0 and add VioCore, VioEngagementUI, VioCastingUI to your target.
2. Initialize at Startup
import VioCore
@main
struct MyApp: App {
init() {
VioSDK.configure(apiKey: "YOUR_VIO_API_KEY")
}
var body: some Scene {
WindowGroup { ContentView() }
}
}Your API key is available in the Vio Dashboard → Apps.
3. Connect to a Broadcast
Call VioSDK.setContent(id:) when the user opens a stream. The id is the externalId of the broadcast configured in the Dashboard:
import VioCore
// When the user opens a stream
await VioSDK.setContent(
id: "real-madrid-vs-barcelona-2025-01-24",
userId: currentUser.id, // optional — enables per-user analytics
country: currentUser.country // optional — market availability
)From this point, the SDK:
- Discovers the active campaign for this broadcast
- Opens a WebSocket connection
- Applies sponsor branding (logo, colors) from the backend
- Polls and contests are pushed in real-time as scheduled in the Dashboard
4. Show the Engagement Overlay
import SwiftUI
import VioCastingUI
struct StreamView: View {
let broadcastId: String
var body: some View {
ZStack {
// Your video player
VideoPlayerView()
// Vio overlay — handles polls, contests, sponsor badge automatically
VioEngagementOverlay()
}
.task {
await VioSDK.setContent(id: broadcastId)
}
.onDisappear {
VioSDK.disconnect()
}
}
}5. Disconnect When Stream Ends
VioSDK.disconnect()What Happens Automatically
Once VioSDK.setContent(id:) is called:
- ✅ Campaign discovered via API — no hardcoded IDs
- ✅ WebSocket connected for real-time events
- ✅ Sponsor logo and colors applied from the backend
- ✅ Polls appear at configured minutes
- ✅ Contests shown when triggered from the Dashboard
- ✅ Product overlays shown at Sponsor Moments
- ✅ Lineup delivered 10 minutes before kickoff
Next Steps
- Core Concepts — Understand CampaignManager and the engagement flow
- User Identification — Per-user analytics and purchase attribution
- Analytics & Tracking — Events and reporting
- Components — All available SwiftUI components
Last updated on