使用来自 iOS 7.1.2 Safari 的 Firebase 身份验证
Using Firebase Authentication from iOS 7.1.2 Safari
我看到这个错误:
Error: This operation is not supported in the environment this
application is running on. "location.protocol" must be http, https or
chrome-extension and web storage must be enabled.
当我使用:
firebase.auth().signInWithPopup(provider)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log('popup', error);
//webSettings.setDomStorageEnabled(true);
firebase.auth().signInWithRedirect(provider)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log('redirect', error);
firebase.auth().signInAnonymously().catch(function(error) {
console.log('anonymous', error);
});
});
});
通过弹出窗口和重定向的前两次登录尝试失败。它似乎只发生在 iOS Safari 上。
我看到其他人报告了 Cordova 的问题,但我没有看到答案,而且我只使用 web 和 firebase。不是 Cordova 或 ionic 等
匿名登录在 iOS 上有效,但这只是一个测试,而不是我们想要使用的。
如果您想测试它,可以在 iOS
上使用 Safari 中的 https://meetup-reporter.firebaseapp.com/
返回的 Promise 中错误对象的示例转储是:
{"code": "auth/operation-not-supported-in-this-environment",
"constructor": function (a, b)
{this.code="auth/"+a;this.message=b||Xf[a]||"";}, "F": function ()
{return{code:this.code,message:this.message}}, "line": 44, "message":
"This operation is not supported in the environment this application
is running on. \"location.protocol\" must be http, https or
chrome-extension and web storage must be enabled.", "sourceURL":
"https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js",
"stack":
"https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:44:638\nhttps://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:258\nA@https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:44:545\nD@https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:242\nsignInWithPopup@https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:241:48\na@https://meetup-reporter.firebaseapp.com/__/firebase/4.1.2/firebase-auth.js:260:432\nhttps://meetup-reporter.firebaseapp.com/scripts/main.js:430:36",
"toJSON": function () {var
a=Array.prototype.slice.call(arguments);a:{var
e=Array.prototype.slice.call(a);var l=0;for(var
n=!1,C=0;Cl||l>=fk.length)throw new N("internal-error","Argument
validator received an unsupported number of arguments.");e=fk[l]+"
argument "+(e.name?'"'+e.name+'" ':"")+"must be "+e.N+".";break
a}e=null}}if(e)throw new N("argument-error",d+" failed: "+e);return
b.apply(this,a);}}
signInWithRedirect 现在在 Cordova 中实际工作:https://firebase.google.com/docs/auth/web/cordova
signInWithPopup 和 signInWithRedirect 也应该适用于 iOS7 及更高版本。我刚刚在 iOS 7 设备上测试了它们,它们都可以工作。您遇到的情况很可能是您在禁用网络存储的 Safari Private/Incognito 模式下使用此操作。这些操作依赖于网络存储,以便将 OAuth 结果安全地传送到父页面。当发生这种情况时,您将需要要求您的用户切换到常规模式,或者您可以使用 Google 登录 JS SDK 获取 OAuth 凭据,然后 signInWithCredential。我认为它可以在隐身模式下工作。
我看到这个错误:
Error: This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.
当我使用:
firebase.auth().signInWithPopup(provider)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log('popup', error);
//webSettings.setDomStorageEnabled(true);
firebase.auth().signInWithRedirect(provider)
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.log('redirect', error);
firebase.auth().signInAnonymously().catch(function(error) {
console.log('anonymous', error);
});
});
});
通过弹出窗口和重定向的前两次登录尝试失败。它似乎只发生在 iOS Safari 上。
我看到其他人报告了 Cordova 的问题,但我没有看到答案,而且我只使用 web 和 firebase。不是 Cordova 或 ionic 等
匿名登录在 iOS 上有效,但这只是一个测试,而不是我们想要使用的。
如果您想测试它,可以在 iOS
上使用 Safari 中的 https://meetup-reporter.firebaseapp.com/返回的 Promise 中错误对象的示例转储是:
{"code": "auth/operation-not-supported-in-this-environment", "constructor": function (a, b) {this.code="auth/"+a;this.message=b||Xf[a]||"";}, "F": function () {return{code:this.code,message:this.message}}, "line": 44, "message": "This operation is not supported in the environment this application is running on. \"location.protocol\" must be http, https or chrome-extension and web storage must be enabled.", "sourceURL": "https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js", "stack": "https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:44:638\nhttps://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:258\nA@https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:44:545\nD@https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:242\nsignInWithPopup@https://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:241:48\na@https://meetup-reporter.firebaseapp.com/__/firebase/4.1.2/firebase-auth.js:260:432\nhttps://meetup-reporter.firebaseapp.com/scripts/main.js:430:36", "toJSON": function () {var a=Array.prototype.slice.call(arguments);a:{var e=Array.prototype.slice.call(a);var l=0;for(var n=!1,C=0;Cl||l>=fk.length)throw new N("internal-error","Argument validator received an unsupported number of arguments.");e=fk[l]+" argument "+(e.name?'"'+e.name+'" ':"")+"must be "+e.N+".";break a}e=null}}if(e)throw new N("argument-error",d+" failed: "+e);return b.apply(this,a);}}
signInWithRedirect 现在在 Cordova 中实际工作:https://firebase.google.com/docs/auth/web/cordova signInWithPopup 和 signInWithRedirect 也应该适用于 iOS7 及更高版本。我刚刚在 iOS 7 设备上测试了它们,它们都可以工作。您遇到的情况很可能是您在禁用网络存储的 Safari Private/Incognito 模式下使用此操作。这些操作依赖于网络存储,以便将 OAuth 结果安全地传送到父页面。当发生这种情况时,您将需要要求您的用户切换到常规模式,或者您可以使用 Google 登录 JS SDK 获取 OAuth 凭据,然后 signInWithCredential。我认为它可以在隐身模式下工作。