使用 Firebase 的 RN Facebook 身份验证 - 未创建 Firebase 应用“[DEFAULT]”
RN Facebook auth with Firebase - No Firebase App '[DEFAULT]' has been created
我正在尝试在基于 firebase 的 react-native 应用程序 (IOS) 上实施 Facebook 身份验证。
- 在 Facebook 开发者仪表板中配置了我的应用程序。
- 在 firebase 仪表板中配置了 facebook 身份验证详细信息并启用了身份验证。
- 向我的 plist.info 文件添加了必要的行
据我所知,
- 我正在从 facebook 获取令牌
- 我在 facebook 控制台中看到身份验证成功,并在我的 faceook 帐户中收到警报
但是函数“signInWithCredential”失败并出现错误:
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
我正在调用此函数之前初始化 firebase 配置..所以我不确定真正的问题是什么:o
任何其他 firebase query/call 工作正常。
我的facebook认证功能(网上找的):
const facebookLogin = 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 = auth.FacebookAuthProvider.credential(data.accessToken);
// Sign-in the user with the credential
return auth().signInWithCredential(facebookCredential); ** --> FAILS HERE **
};
我很乐意为大家提供任何帮助..
谢谢!
好的,我明白了,
需要在连接后导入我的 firebase 对象,并使用它来调用 'auth' 操作:
// Create a Firebase credential with the AccessToken
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
// Sign-in the user with the credential
return firebase.auth().signInWithCredential(facebookCredential);
我正在尝试在基于 firebase 的 react-native 应用程序 (IOS) 上实施 Facebook 身份验证。
- 在 Facebook 开发者仪表板中配置了我的应用程序。
- 在 firebase 仪表板中配置了 facebook 身份验证详细信息并启用了身份验证。
- 向我的 plist.info 文件添加了必要的行
据我所知,
- 我正在从 facebook 获取令牌
- 我在 facebook 控制台中看到身份验证成功,并在我的 faceook 帐户中收到警报
但是函数“signInWithCredential”失败并出现错误:
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
我正在调用此函数之前初始化 firebase 配置..所以我不确定真正的问题是什么:o
任何其他 firebase query/call 工作正常。
我的facebook认证功能(网上找的):
const facebookLogin = 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 = auth.FacebookAuthProvider.credential(data.accessToken);
// Sign-in the user with the credential
return auth().signInWithCredential(facebookCredential); ** --> FAILS HERE **
};
我很乐意为大家提供任何帮助.. 谢谢!
好的,我明白了, 需要在连接后导入我的 firebase 对象,并使用它来调用 'auth' 操作:
// Create a Firebase credential with the AccessToken
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
// Sign-in the user with the credential
return firebase.auth().signInWithCredential(facebookCredential);