我正在使用 FirebaseUI-Authentication . 使用电子邮件或Google帐户登录是成功的,但使用 Facebook 登录无效 . 在AuthUI活动启动并尝试使用Facebook登录后,不会调用 onActivityResult()
. 登录后尝试将应用程序停留在加载窗口 . logcat输出FirebaseApp日志:
通知背景状态更改侦听器 .
在Facebook应用程序仪表板上,我设置了有效的OAuth重定向URI,正如firebase指南所述,我将应用程序公开(如果它是公共的还是处于开发状态,这是否重要?) . 在Firebase控制台中,我启用了Facebook登录并设置了应用程序ID和应用程序密钥 .
This是一个视频录制,显示登录Facebook后点击登录活动后发生的情况 .
为什么不叫 onActivityResult()
?
MainActivity:
/**
* Use this method to start the FirebaseUI sign in activity.
*/
public void switchToSignIn() {
this.activity.startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(
AuthUI.EMAIL_PROVIDER,
AuthUI.GOOGLE_PROVIDER,
AuthUI.FACEBOOK_PROVIDER)
.build(), RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RC_SIGN_IN) {
if (resultCode == this.activity.RESULT_OK) {
// user is signed in!
Log.d(Constants.TAG_LoginHandler, "Sign in result: RESULT_OK");
logUserInfo();
tryAccessMainFragment();
} else {
Log.d(Constants.TAG_LoginHandler, "Sign in result: RESULT_CANCELLED");
// user is not signed in. Maybe just wait for the user to press
// "sign in" again, or show a message
}
}
}
build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.firebaseui:firebase-ui:0.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:1.3.0'
}
apply plugin: 'com.google.gms.google-services'
2 回答
尝试更新到新版本的Google Play服务,他们已修复了一些与Firebase身份验证相关的问题 . (虽然他们没有特别提到Facebook登录)
Google Play services updated to 9.0.2 Google Play服务版本9.0.2版现已推出 . 此版本修复了Firebase身份验证的已知问题,其中FirebaseAuthApi在某些设备上不可用 .
https://developers.google.com/android/guides/releases
如果您使用的是FirebaseUI,则必须将此确切字符串放在strings.xml中:
APPID 可以在 developers.facebook.com dashboard 上找到 .
见firebaseui-auth readme
另外一定要在facebook应用中添加你的android密钥哈希和OAuth firebase URL .