【发布时间】:2020-10-11 05:16:46
【问题描述】:
我正在使用 AWS Amplify SDK 进行 Cognito 集成。实际上,我根据可用的文档here 成功集成了用户登录和注册流程。但是,成功登录后,如果我们重新启动应用程序,则用户会话不会持续存在。 Amplify.Auth.fetchAuthSession() 总是以 false 返回 isSignedIn。我不知道我在哪里制造问题。请在下方找到“登录”sn-p。
fun onSingIn(view: View) {
Amplify.Auth.signIn(
email.value,
password.value,
{ result ->
Log.i(TAG, if (result.isSignInComplete) "Sign in succeeded" else "Sign in not complete")
if (result.isSignInComplete) {
view.context.let {
it.startActivity(Intent(it, FeedActivity::class.java))
signInStatus.postValue(true)
}
}
},
{ error ->
view.context.let {
var message = it.getString(R.string.something_went_wrong)
when (error.cause) {
is UserNotConfirmedException ->{
email.value?.let {emailAddress ->
val direction =LoginFragmentDirections
.actionLoginFragmentToEmailVerificationCodeFragment(emailAddress)
view.findNavController().navigate(direction)
}
}
is UserNotFoundException ->
message = it.getString(R.string.credentilas_incorrect)
else->
viewModelScope.launch(Dispatchers.Main) { it.showToast(message) }
}
Log.e(TAG, error.toString())
}
}
)
}
【问题讨论】:
标签: android amazon-web-services amazon-cognito aws-amplify aws-userpools