authData
Provides a flow of authentication data to be used by the SDK to load relevant user-specific data.
Overview
This method returns a StateFlow that the SDK observes to get the current authentication state. Your app should emit authentication data when a user is logged in, and emit null when the user is logged out. The SDK uses this information to personalize content and features.
Syntax
abstract fun authData(): StateFlow<MaestroAuthData?>?
Example
class MyActivity : ComponentActivity(), MaestroEventDelegate {
private val _authDataState = MutableStateFlow<MaestroAuthData?>(null)
override fun authData(): StateFlow<MaestroAuthData?> {
return _authDataState
}
// When user logs in
fun onUserLoggedIn(userId: String, token: String) {
_authDataState.value = MaestroAuthData(
userId = userId,
token = token,
)
}
// When user logs out
fun onUserLoggedOut() {
_authDataState.value = null
}
}
Notes
- Emit
nullwhen the user is logged out - The SDK automatically responds to auth state changes
- Used for personalized features like betting, fantasy, and user-specific content
- Update the flow whenever the auth state changes
- The flow should remain active for the SDK's lifecycle
Related Methods
- onLoginClicked() - Handles login button clicks