Skip to main content
Getting Started | Virtual Stadium | Sportradar Developer Documentation
Virtual Stadium, Moderation, Engagement Tools, BET
Last updated 7 months ago
Is this site helpful? This guide will help you integrate the Virtual Stadium Data SDK into your application and get up and running quickly.
# Overview
To integrate the Virtual Stadium Data SDK:
Install and initialize the SDK
Authenticate with a JWT token using LoginManager
Initialize chat channels with ChatManager
Subscribe to state flows for real-time updates
Handle user interactions (send messages, reactions, etc.)
This guide walks you through each step with complete code examples.
# Prerequisites
SDK Version Requirements
Android : Minimum SDK 23 (Android 6.0)
iOS : Minimum iOS 11.0
Authentication
Valid JWT token for user authentication — see the JWT Authentication guide for setup instructions
API key from Virtual Stadium (if applicable)
# Step 1: SDK Initialization
The SDK uses Koin for dependency injection and is automatically initialized when you start using any services.
Complete the Installation & Setup guide before proceeding.
Step 2: Authentication
Before using any chat functionality, you must authenticate with a JWT token using LoginManager.
Monitor the loginState flow to track authentication status and handle different login states (LOGGED_IN, ERROR, LOADING, LOGGED_OUT).
All SDK features require successful authentication. Ensure login completes before initializing chat channels.
kotlin
class MainViewModel : ViewModel (), KoinComponent {
private val loginManager: LoginManager by inject ()
fun initialize () {
// Monitor login state
loginManager.loginState. collect { loginState ->
when (loginState.loginStatus) {
LoginStatus.LOGGED_IN -> {
# Step 3: Initialize Chat ChannelOnce authenticated, create and manage chat channels using ChatManager.
Use getOrAddChannel() to get an existing channel or create a new one. The method returns a ChatChannel instance for message operations.
Subscribe to various state flows:
MessagesState - Chat messages and pagination
UserState - User status (bans, timeouts)
ChatSettings - Channel configuration
# Step 4: Basic Chat OperationsNow you can perform basic chat operations using the ChatChannel instance.
Common operations include:
Send messages - Post new messages to the channel
React to messages - Add emoji reactions
Load history - Paginate through previous messages
kotlin
// Send a message
fun sendMessage (text: String ) {
channel?. sendMessage (
message = text,
onFailure = {
// Handle send failure
}
)
}
// React to a message
fun reactToMessage (message: Message , reactionType: ReactionType ) {
channel?. toggleReactionOnMessage (message, reactionType)
Here's the recommended integration flow:
Initialize SDK → SDK auto-initializes with Koin dependency injection
Login → Authenticate with JWT token using LoginManager
Monitor Login State → Wait for successful authentication (LOGGED_IN status)
Initialize Chat Channel → Create/get channel with ChatManager.getOrAddChannel()
Subscribe to States → Observe messages, user status, and settings flows
Handle User Interactions → Send messages, reactions, share bets, etc.
Manage Lifecycle → Stop/resume channels based on app lifecycle
Cleanup → Destroy channels and logout when done
SDK Services
Review all available services and their purposes.
Authentication
Learn about login and user state management.
Chat Features
Explore messaging, reactions, and bet sharing.
// SDK is ready to use
initializeChat ()
}
LoginStatus.ERROR -> {
// Handle login error
handleLoginError (loginState.loginError)
}
// Handle other states...
}
}
// Perform login
loginManager. login ( "YOUR_JWT_TOKEN" )
}
}
ChatViewModel
:
ViewModel
(),
KoinComponent
{
private val chatManager: ChatManager
get () = get ()
val userProvider: UserProvider
get () = get ()
private val settingsProvider: SettingsProvider
get () = get ()
private val channel: ChatChannel ? = null
val settings: StateFlow < ChatSettings > = settingsProvider.settings
fun initializeChannel (channelId: String ) {
//Initializing channel and states!"
channel = chatManager. getOrAddChannel (channelId = channelId, getChannelStats = true )
}
fun loadPreviousPage () {
channel?. loadPreviousPage ()
}
fun sendMessage (message: String ) {
channel?. sendMessage (message)
}
fun replyToMessage (messageId: String , message: String ) {
channel?. replyToMessage (message, messageId)
}
fun toggleReactionOnMessage (reaction: ReactionType , message: Message ) {
channel?. toggleReactionOnMessage (message, reaction)
}
fun addReaction (reaction: ReactionType , message: Message ) {
channel?. reactToMessage (message, reaction)
}
fun reportMessage (messageId: String , reportedSuccessfully: ( Boolean ) -> Unit ) {
channel?. reportMessage (
messageId = messageId,
onSuccess = { reportedSuccessfully ( true ) },
onFailure = { reportedSuccessfully ( false ) },
)
}
fun shareNewBet (
betPayload: BetPayload ,
showStake: Boolean ,
comment: String ,
) {
channel. value ?. shareBet (
betPayload = betPayload,
comment = comment,
showStake = showStake,
onSuccess = {
//Successfully shared a bet
},
onFailure = {
//Failed to share bet
},
)
}
fun getAllBetShares () {
channel?. getAllBetShares ()
}
fun loadMoreBetShares () {
channel?. loadMoreMyBetShares ()
}
fun getMyBetShares () {
channel?. getMyBetShares ()
}
fun loadMoreMyBetShares () {
channel?. loadMoreMyBetShares ()
}
fun copySharedBet (messageId: String ) {
channel?. copySharedBet (messageId)
}
fun filterTags (query: String ) {
channel?. filterTags (query)
}
fun stopChannel (channelId: String ) {
// Clear channel and states
chatManager. removeChannel (channelId)
channel = null
}
fun restartChannel () {
channel?. restart ()
}
}
}
// Load previous messages
fun loadPreviousPage () {
channel?. loadPreviousPage ()
}