Configuration
The Vio SDK is configured once at app startup via vio-config.json. The Dashboard handles all campaign, broadcast, poll, and sponsor configuration — no code changes needed after setup.
Configuration File (vio-config.json)
Add to your Xcode project and include in Build Phases → Copy Bundle Resources.
Full Example
{
"apiKey": "YOUR_VIO_API_KEY",
"environment": "production",
"campaigns": {
"webSocketBaseURL": "wss://api.vio.live",
"restAPIBaseURL": "https://api.vio.live",
"campaignApiKey": "YOUR_CAMPAIGN_API_KEY",
"autoDiscover": true
},
"theme": {
"name": "My Theme",
"mode": "automatic",
"lightColors": {
"primary": "#007AFF"
},
"darkColors": {
"primary": "#0A84FF"
}
},
"marketFallback": {
"countryCode": "NO",
"currencyCode": "NOK"
},
"localization": {
"defaultLanguage": "no",
"fallbackLanguage": "en"
}
}campaigns Section (Required for Engagement)
This is the key section that enables live engagement. All values are available in the Vio Dashboard → Apps.
| Field | Description |
|---|---|
webSocketBaseURL | WebSocket server URL (e.g. wss://api.vio.live) |
restAPIBaseURL | REST API base URL (e.g. https://api.vio.live) |
campaignApiKey | API key from Dashboard — used for broadcast discovery and WS auth |
autoDiscover | true — SDK auto-discovers the campaign when you call setBroadcastContext() |
Development: Use
wss://api-dev.vio.liveandhttps://api-dev.vio.livefor the staging backend.
Loading Configuration
import VioCore
@main
struct MyApp: App {
init() {
// Auto-detects vio-config.json in app bundle
ConfigurationLoader.loadConfiguration(userCountryCode: "NO")
}
var body: some Scene {
WindowGroup { ContentView() }
}
}Loading Options
// Auto-detect config file (recommended)
ConfigurationLoader.loadConfiguration(userCountryCode: "NO")
// Load specific file
ConfigurationLoader.loadConfiguration(fileName: "vio-config-viaplay", userCountryCode: "NO")
// Programmatic (no JSON file)
VioConfiguration.configure(
apiKey: "your-api-key",
environment: .production,
campaignConfig: CampaignConfiguration(
webSocketBaseURL: "wss://api.vio.live",
restAPIBaseURL: "https://api.vio.live",
campaignApiKey: "your-campaign-key",
autoDiscover: true
)
)Environment Variables (Scheme Override)
Set in Xcode: Edit Scheme → Run → Environment Variables
| Variable | Values | Description |
|---|---|---|
VIO_CONFIG_TYPE | viaplay, tv2, automatic | Selects vio-config-<type>.json |
VIO_ENVIRONMENT | production, development | Override environment |
VIO_USER_COUNTRY | NO, SE, DK… | Override market country |
Theme
Sponsor colors override the theme at runtime — they come from the Dashboard automatically. Your theme is used as a fallback.
{
"theme": {
"mode": "automatic",
"lightColors": {
"primary": "#007AFF",
"background": "#FFFFFF",
"surface": "#F2F2F7"
},
"darkColors": {
"primary": "#0A84FF",
"background": "#000000",
"surface": "#1C1C1E"
}
}
}Theme modes: automatic (follows iOS system) · light · dark
Market Availability
The SDK checks if your streaming service is available in the user’s market. If the market is not available, the SDK disables itself silently.
// Check availability
let available = VioConfiguration.shared.isMarketAvailable
// Check specific country
let isNorway = VioConfiguration.shared.isMarketAvailableForCountry("NO")Localization
{
"localization": {
"defaultLanguage": "no",
"fallbackLanguage": "en",
"translationsFile": "vio-translations"
}
}The SDK includes built-in Norwegian (no), English (en), and Swedish (sv) translations. Custom translations can be added via translationsFile.
Runtime Updates
// Update theme at runtime
VioConfiguration.updateTheme(.dark)
// Update cart config
VioConfiguration.updateCartConfiguration(
CartConfiguration(floatingCartPosition: .bottomRight)
)Troubleshooting
| Problem | Fix |
|---|---|
| Config not loading | Ensure vio-config.json is in Copy Bundle Resources |
hasEngagement: false | Check campaignApiKey matches the app in the Dashboard |
| WebSocket not connecting | Verify webSocketBaseURL and that the broadcast status is live in Dashboard |
| Polls not appearing | Check broadcast externalId in Dashboard matches the broadcastId you pass to setBroadcastContext |
Next Steps
- Core Concepts — CampaignManager and the engagement flow
- Dashboard Setup — Configure broadcasts and polls
- Components — Available SwiftUI components