Android Kotlin coroutine support
import kotlinx.coroutines.*
class MyAwesomeViewModel(application: MyAwesomeApplication) : AndroidViewModel(application) {
// Other methods
// This is called when login button is clicked.
fun login() {
viewModelScope {
withContext(Dispatchers.IO) {
try {
val app = getApplication<MyAwesomeApplication>()
val state = app.authgear.authenticate(AuthenticateOptions(redirectUri = "com.myapp://host/path"))
// User is logged in!
} catch (e: Throwable) {
// Something went wrong.
}
}
}
}
}Last updated
Was this helpful?