API Reference
Reference for public APIs in VioCore, VioEngagementSystem, VioUI, and VioCastingUI.
VioCore
VioConfiguration
Global configuration singleton. Call configure() once at startup.
import VioCore
let config = VioConfiguration.shared
let isConfigured = config.isConfigured
let isAvailable = config.isMarketAvailable
let shouldUse = config.shouldUseSDK // isConfigured && isMarketAvailable
VioConfiguration.updateTheme(.dark)
VioConfiguration.updateCartConfiguration(CartConfiguration(...))VioSDK
The main entry point. Call configure once at startup, setContent when a stream opens.
import VioCore
// Initialize (call once at app startup)
VioSDK.configure(apiKey: "YOUR_VIO_API_KEY")
// Connect to a broadcast
await VioSDK.setContent(
id: "real-madrid-vs-barcelona-2025-01-24",
userId: currentUser.id, // optional
country: currentUser.country // optional
)
// Disconnect when stream ends
VioSDK.disconnect()CampaignManager
Read-only access to campaign state after VioSDK.setContent(id:) is called.
import VioCore
// Read state
let campaign = CampaignManager.shared.currentCampaign
let context = CampaignManager.shared.currentBroadcastContext
let isConnected = CampaignManager.shared.isConnected
let isActive = CampaignManager.shared.isCampaignActiveBroadcastContext
public struct BroadcastContext: Codable, Equatable {
public let broadcastId: String // Required — matches externalId in Dashboard
public let broadcastName: String? // Optional display name
public let startTime: String? // ISO 8601
public let channelId: Int?
public let metadata: [String: String]?
}Campaign
public struct Campaign: Codable, Identifiable {
public let id: Int
public let startDate: String?
public let endDate: String?
public let isPaused: Bool?
public let campaignLogo: String?
public let sponsor: SponsorInfo?
public let broadcastContext: BroadcastContext?
}SponsorInfo
Sponsor identity delivered from the backend automatically.
public struct SponsorInfo {
public let name: String?
public let logoUrl: String?
public let avatarUrl: String?
public let primaryColor: String? // e.g. "#F5153B"
public let badgeText: String?
}VioEngagementSystem
EngagementManager
Manages poll and contest state. Updated automatically via WebSocket after setBroadcastContext.
import VioEngagementSystem
@StateObject var engagement = EngagementManager.shared
// Get active polls/contests for the current broadcast
guard let context = CampaignManager.shared.currentBroadcastContext else { return }
let polls = engagement.getActivePolls(for: context)
let contests = engagement.getActiveContests(for: context)
// Check prior participation
let hasVoted = engagement.hasVotedInPoll(pollId)
let hasEntered = engagement.hasParticipatedInContest(contestId)
// Vote on a poll
try await engagement.voteInPoll(
pollId: poll.id,
optionId: selectedOptionId,
broadcastContext: context
)
// Participate in a contest
try await engagement.participateInContest(
contestId: contest.id,
broadcastContext: context
)EngagementError
public enum EngagementError: LocalizedError {
case pollNotFound
case pollClosed
case alreadyVoted
case contestNotFound
// ...
}VioUI
ProductService
import VioUI
let product = try await ProductService.shared.loadProduct(
productId: "408841",
currency: "NOK",
country: "NO"
)
let products = try await ProductService.shared.loadProducts(
productIds: [408841, 408895],
currency: "NOK",
country: "NO"
)
ProductService.shared.clearCache()CartManager
import VioUI
@StateObject private var cartManager = CartManager()
await cartManager.addProduct(product)
cartManager.isCheckoutPresented = true
let count = cartManager.cart?.lineItems.count ?? 0VioEnvironment
public enum VioEnvironment {
case development // https://api-dev.vio.live
case sandbox // https://api-dev.vio.live
case production // https://api.vio.live
}Design System
import VioDesignSystem
VioColors.primary // Sponsor primary (from backend) or theme fallback
VioColors.background
VioColors.surface
VioColors.text
VioColors.textSecondary
VioSpacing.xs // 4pt
VioSpacing.sm // 8pt
VioSpacing.md // 16pt
VioSpacing.lg // 24pt
VioSpacing.xl // 32pt
VioTypography.largeTitle
VioTypography.title
VioTypography.body
VioTypography.captionNext Steps
- Components — SwiftUI component library
- Zero-Config SDK — Initialization reference
- Complete Setup — Full integration example
Last updated on