首页 文章

使用iOS 7.1.2 Safari中的Firebase身份验证

提问于
浏览
0

我看到这个错误:

错误:运行此应用程序的环境不支持此操作 . “location.protocol”必须是http,https或chrome-extension,并且必须启用网络存储 .

我用的时候:

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或离子等 .

匿名登录适用于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”:“此操作不是在此应用程序运行的环境中受支持 . \“location.protocol \”必须是http,https或chrome-extension,并且必须启用网络存储 . “,”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/火力-auth.js:44:545 \ ND @ HTTPS://meetup-reporter.firebaseapp.com//firebase/4.1.2/firebase-auth.js:45:242 \ nsignInWithPopup @ HTTPS://聚会 - 报道.firebaseapp.com //火力/ 4.1.2 /火力-auth.js:241:48 \呐@ HTTPS://meetup-reporter.firebaseapp.com/__/firebase/4.1.2/fire base-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收到不支持的参数数量 . ”); e = fk [l]“argument”(e.name?'“'e.name'”':“”)“如果(e)抛出新的N(“参数错误”,d“失败:”e);返回b.apply(this,a);}},必须是“eN” . “; break a} e = null}}

1 回答

  • 0

    signInWithRedirect现在实际上在Cordova中工作:https://firebase.google.com/docs/auth/web/cordova signInWithPopup和signInWithRedirect也适用于iOS7及以上版本 . 我刚刚在iOS 7设备上进行了测试,但两者都有效 . 您遇到的可能是您在禁用Web存储的Safari专用/隐身模式下使用此操作 . 这些操作依赖于Web存储,以便将OAuth结果安全地传递到父页面 . 当发生这种情况时,您需要让用户切换到常规模式,或者您可以使用Google登录JS SDk获取OAuth凭据,然后使用signInWithCredential . 我认为它可能在隐身模式下工作 .

相关问题