Skip to Content
Swift SDKConfiguration

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.

FieldDescription
webSocketBaseURLWebSocket server URL (e.g. wss://api.vio.live)
restAPIBaseURLREST API base URL (e.g. https://api.vio.live)
campaignApiKeyAPI key from Dashboard — used for broadcast discovery and WS auth
autoDiscovertrue — SDK auto-discovers the campaign when you call setBroadcastContext()

Development: Use wss://api-dev.vio.live and https://api-dev.vio.live for 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

VariableValuesDescription
VIO_CONFIG_TYPEviaplay, tv2, automaticSelects vio-config-<type>.json
VIO_ENVIRONMENTproduction, developmentOverride environment
VIO_USER_COUNTRYNO, SE, DKOverride 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

ProblemFix
Config not loadingEnsure vio-config.json is in Copy Bundle Resources
hasEngagement: falseCheck campaignApiKey matches the app in the Dashboard
WebSocket not connectingVerify webSocketBaseURL and that the broadcast status is live in Dashboard
Polls not appearingCheck broadcast externalId in Dashboard matches the broadcastId you pass to setBroadcastContext

Next Steps

Last updated on