运行此应用程序的环境不支持此操作."location.protocol"必须是http或https

Joe*_*cio 4 facebook firebase react-native firebase-authentication

使用Firebase和React Native将用户身份验证到我的应用中.

我注意到的一件事是当尝试使用facebook登录时,我抛出了这个错误:

运行此应用程序的环境不支持此操作."location.protocol"必须是http或https.

真的不确定如何解决它

boj*_*eil 10

您必须使用signInWithPopup/Redirect.目前仅在浏览器环境中支持此功能.您需要使用一些本机库(facebook/google)来检索相应的OAuth访问令牌.完成后,您可以调用signInWithCredential来登录Firebase用户:

firebase.auth().signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken))
Run Code Online (Sandbox Code Playgroud)