【发布时间】:2017-03-10 17:02:28
【问题描述】:
我有 Facebook 登录页面(我正在使用 Firebase Auth),当我在设备上运行我的应用并单击登录按钮时,我收到错误消息:
运行此应用程序的环境不支持此操作。 “location.protocol”必须是 http 或 https 并且必须启用网络存储。
错误代码是:
auth/operation-not-supported-in-this-environment
如果我在我的谷歌浏览器中运行这个应用程序,它的效果很好。问题出在哪里?
谢谢。
登录代码:
var provider = new firebase.auth.FacebookAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Facebook Access Token. You can use it to access the Facebook API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
console.log(user);
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorMessage);
console.log(errorCode);
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
【问题讨论】:
-
signInWithPopup 目前在 Cordova 中不受支持。作为一种解决方法,您可以为 Cordova 使用 Facebook 登录库,然后使用访问令牌调用 signInWithCredential()。
-
我该怎么做?你有一个例子吗? @ChanningHuang
标签: cordova firebase ionic-framework firebase-authentication