onLoginClicked
Notifies the client app that the (Fantasy) login card was clicked.
Overview
The SDK calls this method when a user clicks on a login card within the panel, typically in Fantasy or betting features. Your app should respond by initiating the login flow to authenticate the user.
Syntax
abstract fun onLoginClicked()
Example
override fun onLoginClicked() {
// Start your app's login flow
startLoginActivity()
}
private fun startLoginActivity() {
val intent = Intent(this, LoginActivity::class.java)
startActivityForResult(intent, REQUEST_CODE_LOGIN)
}
// After successful login
private fun onLoginSuccess(userId: String, token: String) {
// Update auth data flow
_authDataState.value = MaestroAuthData(
userId = userId,
token = token,
)
}
// Alternative: Show login bottom sheet
override fun onLoginClicked() {
lifecycleScope.launch {
showLoginBottomSheet()
}
}
@Composable
private fun showLoginBottomSheet() {
// Display login UI
LoginBottomSheet(
onLoginSuccess = { userId, token ->
_authDataState.value = MaestroAuthData(userId, token)
}
)
}
Notes
- Initiate your app's login flow when this is called
- After successful login, update the
authData()flow - Consider a seamless login experience (bottom sheet, modal, etc.)
- Handle cases where the user cancels the login
Related Methods
- authData() - Provides authentication data to the SDK