由于try 使用Firebase AuthUI登录时出错,我的应用程序被Amazon Appstore拒绝.
我决定做一些研究,发现所有亚马逊Fire设备都没有运行Google Play服务.我安装了一个没有谷歌服务的新模拟器,也得到了一个错误.
奇怪的是,Firebase Auth的20.0.0版引入了"The Firebase Authentication Android library now works on devices without Google Play services."功能.
代码
public void signIn() {
List<AuthUI.IdpConfig> listProviders = Arrays.asList(
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build(),
new AuthUI.IdpConfig.YahooBuilder().build(),
new AuthUI.IdpConfig.EmailBuilder().build()
);
// Create and launch sign-in intent
Intent intentSignIn = AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(listProviders)
.setTheme(R.style.LoginTheme)
.setLogo(R.drawable.login_icon)
.setTosAndPrivacyPolicyUrls(
"URL",
"URL")
.build();
activityResultLauncherSignIn.launch(intentSignIn);
}
// https://developer.android.com/training/basics/intents/result
private final ActivityResultLauncher<Intent> activityResultLauncherSignIn = registerForActivityResult(
new FirebaseAuthUIActivityResultContract(),
this::onSignInResult
);
private void onSignInResult(FirebaseAuthUIAuthenticationResult firebaseAuthUIAuthenticationResult) {
IdpResponse idpResponse = firebaseAuthUIAuthenticationResult.getIdpResponse();
if (firebaseAuthUIAuthenticationResult.getResult代码() == RESULT_OK) {
if (firebaseUser != null && firebaseUser.getEmail() != null && !firebaseUser.isEmailVerified())
sendVerificationEmail();
} else {
// Sign in failed. If response is null the user canceled the sign-in flow using the back button. Otherwise check response.getError().getError代码() and handle the error.
if (idpResponse != null && idpResponse.getError() != null) {
Log.e(TAG, "Problem with Firebase authentication: " + idpResponse.getError().getError代码());
}
}
}
错误: Firebase身份验证问题:0
Com.google.android.play.core.install.InstallException:-9:安装错误(-9):Play Store应用程序未安装或不是官方版本.
我正在使用以下依赖项:
implementation platform('com.google.firebase:firebase-bom:32.3.1')
implementation 'com.firebaseui:firebase-ui-auth:8.0.2'
implementation 'com.google.android.gms:play-services-auth:20.7.0'