I have an Android application and I’d like the app splash screen to continue showing until Auth0 has finished logging the user in (i.e. the session has not expired) and has already navigated back to the app. Right now the app navigation happens a couple seconds after the login is complete. Is there an Auth0 login listener or something that I can use to achieve this?
I have the loginWithBrowser
and showUserProfile
functions set up, but the app navigation happens a couple seconds after the login completes so the Auth0 browser screen still shows.
private fun showUserProfile(accessToken: String) {
val client = AuthenticationAPIClient(account)
// With the access token, call `userInfo` and get the profile from Auth0.
client.userInfo(accessToken)
.start(object : Callback<UserProfile, AuthenticationException> {
override fun onFailure(error: AuthenticationException) {
navController.navigate("retry-login")
}
override fun onSuccess(result: UserProfile) {
// We have the user's profile!
CoroutineScope(Dispatchers.IO).launch {
try {
// Own API Call Here
withContext(Dispatchers.Main) {
navController.navigate("home")
}
} catch (e: IOException) {
Log.e("error", "Network error occurred: ${e.message}", e)
withContext(Dispatchers.Main) {
navController.navigate("retry-login")
}
} catch (e: HttpException) {
val errorBody = e.response()?.errorBody()?.string()
Log.e("error", "HTTP error occurred: ${e.message}, Error body: $errorBody", e)
navController.navigate("retry-login")
} catch (e: Throwable) {
Log.e("error", "Error occurred: ${e.message}", e)
navController.navigate("retry-login")
}
}
}
})
}
Thanks in advance!