我开发了一个react-native(expo)移动应用程序并尝试使用google帐户登录firebase,但出现错误:
“auth/operation-not-supported-in-this-enviroment。此应用程序运行的环境不支持此操作。“location.protocol”必须是 http、https 或 chrome-extension,并且必须启用 Web 存储”
代码:
loginGoogle() {
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithPopup(provider).then(function(result) {
var token = result.credential.accessToken;
var user = result.user;
return true;
}).catch(function(error) {
alert(error.code + '\n' +
error.message + '\n' +
error.email + '\n' +
error.credential);
return false;
});
}
Run Code Online (Sandbox Code Playgroud) javascript firebase react-native firebase-authentication expo