【发布时间】:2019-02-14 08:48:39
【问题描述】:
根据Firebase documentation:如果用户输入不存在的电子邮件地址,流程会将用户带到注册部分。在我的应用程序中将没有注册部分。如何跳过注册部分并将用户重定向到登录屏幕?
代码如下:
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// RC_SIGN_IN is the request code you passed into startActivityForResult(...) when starting the sign in flow.
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == RESULT_OK) {
//startActivity(SignedInActivity.createIntent(this, response));
finish();
}
else {
// Sign in failed
if (response == null) {
}
if (response.getError().getErrorCode() == ErrorCodes.NO_NETWORK) {
Toast.makeText(this, "No Connection." , Toast.LENGTH_SHORT).show();
return;
}
}
}
}
【问题讨论】:
-
FirebaseUI 对于那些在登录流程中没有做任何特殊事情的人来说只是一种方便的方法。如果您需要定制的东西,最好自己构建它。
标签: android firebase firebase-authentication firebaseui