【发布时间】:2018-11-22 08:59:55
【问题描述】:
我查看了 FirebaseUI 登录方法。在解释的第一页有一个“使用预构建的 UI 登录”,如下所示:Easily add sign-in to your Android app with FirebaseUI。该页面包含以下代码:
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().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);
if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if (resultCode == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// ...
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
}
}
}
但是,当我查看他们关于如何通过 SMS 使用电话进行身份验证的示例时,无法看到此代码,但验证有效。 手机验证码可以在他们的sn-p中看到: PhoneAuthActivity.java
那么我什么时候需要使用这段代码,什么时候不需要呢?这部分的目的是什么?
【问题讨论】:
标签: android firebase firebase-authentication