Im遵循RNFB提供的官方代码示例。。。。低于的代码
问题是你没有通过const facebookCredential = firebase.FacebookAuthProvider.credential(data.accessToken);
这条线。。。。。似乎firebase.FacebookAuthProvider
方法显示为未定义,因此您无法将facebookCredential
变量返回
import { firebase } from '@react-native-firebase/auth';
async function onFacebookButtonPress() {
// 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 = auth.FacebookAuthProvider.credential(data.accessToken);
// Sign-in the user with the credential
return auth().signInWithCredential(facebookCredential);
}
链接的示例似乎缺少auth
变量的声明。我们需要从导入的firebase
模块中获取它。
代替:
auth.FacebookAuthProvider
我们应该使用:
firebase.auth.FacebookAuthProvider