这是我与RNFB Facebook登录有关的第二个问题。
紧跟RNFB提供的official code sample。...下面的代码
问题出在firebase().signInWithCredential(facebookCredential);
行上。...它没有触发Firebase监听器auth().onAuthStateChanged
所有其他代码均按预期方式运行,并且已正确填充facebookCredential
变量
import { firebase } from '@react-native-firebase/auth';
onFacebookButtonPress = async () => {
// Attempt login with permissions
const result = await LoginManager.logInWithPermissions([
'public_profile',
'email',
]);
if (result.isCancelled) {
throw 'User cancelled the login process';
}
// Once signed in, get the users AccesToken
const data = await AccessToken.getCurrentAccessToken();
if (!data) {
throw 'Something went wrong obtaining access token';
}
// Create a Firebase credential with the AccessToken
//const facebookCredential = firebase.FacebookAuthProvider.credential(data.accessToken);
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(
data.accessToken,
);
// Sign-in the user with the credential
firebase().signInWithCredential(facebookCredential);
};
我通过围绕问题线进行尝试/捕获来解决了。原来是因为我曾经使用Google登录。
An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address
我们不应该允许用户使用FB或Google登录吗???
困惑