location.protocol"必须是 http 或 https [英] location.protocol" must be http or https

查看:24
本文介绍了location.protocol"必须是 http 或 https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Cordova + Angular 2 + Ionic 2 开发了一个混合移动应用程序.

I developing a hybrid mobile application using Cordova + Angular 2 + Ionic 2.

在使用 firebase Auth 时,当调用 signInWithPopup() 或 signInWithRedirect() 进行社交登录时,firebase 会返回错误此应用程序运行的环境不支持此操作.location.protocol"必须是 http 或 https."

When using firebase Auth, when calling signInWithPopup() or signInWithRedirect() for social logins, firebase returns error "This operation is not supported in the environment this application is running on. "location.protocol" must be http or https."

这篇文章也有很多评论,关于同一件事:https://firebase.googleblog.com/2016/01/social-login-with-ionic_77.html

There's also a number of comments on this article, about same thing: https://firebase.googleblog.com/2016/01/social-login-with-ionic_77.html

这是因为 location.protocol 是 file://而不是 http/s.所有混合应用都会有这个问题.

This is because the location.protocol is file:// and NOT http/s. All hybrid apps will have this issue.

帮助.

推荐答案

不行

解释:您正在尝试使用 firebase Web SDK 将您的混合应用程序连接到 firebase,因此 firebase 不允许连接.

Explanation: You are trying to connect your hybrid application to firebase using firebase web SDK, so firebase is not allowing to connect.

Web SDK 仅适用于基于 HTTP 和 https 的应用程序

web SDK is allowed for only HTTP and https based applications

所以要连接,请使用移动应用 SDK(Android 和 IOS 有单独的 SDK)

如果您使用 expo 构建您的应用程序,推荐的方法是使用 signInWith 用户名和密码.

If you are using expo to build your application, the recommended way is to use the signInWith UserName and password.

进阶方案:需要相应更改babel config

Advanced solution: you need to change the babel config correspondingly

这篇关于location.protocol"必须是 http 或 https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆