简体   繁体   English

使用Ionic的Firebase signUpWithEmailAndPassword

[英]Firebase signUpWithEmailAndPassword using Ionic

I am using the latest version of Ionic (v1.3.1) and Firebase (v3.1.0). 我使用的是最新版本的Ionic(v1.3.1)和Firebase(v3.1.0)。 I'm trying to do firebase user authentication using the following method: 我正在尝试使用以下方法进行firebase用户身份验证:

firebase.auth().signInWithEmailAndPassword(email, password) firebase.auth()。signInWithEmailAndPassword(电子邮件,密码)

Whilst this method works perfectly when ionic is running in a web browser, when the ionic app is run natively on Android, it throws an error, specifically: 虽然当离子在Web浏览器中运行时此方法可以正常工作,但当离子应用程序在Android上本机运行时,它会抛出错误,具体而言:

'A network error (such as timeout, interrupted connection or unreachable host) has occurred.' '发生网络错误(例如超时,中断连接或无法访问的主机)。

I have made sure the app's config.xml allows access to all URLs so it doesn't appear to be an issue with Ionic. 我确保应用程序的config.xml允许访问所有URL,因此它似乎不是Ionic的问题。

Looking online, it seems that Firebase is possibly blocking the app's browser because it doesn't recognise the app's domain (domains for authentication appear to be whitelisted in the 'OAuth redirect domains' part of the authentication section in the Firebase dashboard). 在线查看,似乎Firebase可能会阻止应用的浏览器,因为它无法识别应用的域(用于身份验证的域似乎在Firebase信息中心的身份验证部分的“OAuth重定向域”部分列入白名单)。

However, there is not way to identify what an Ionic app's domain is (it certainly isn't 'localhost' or 127.0.0.1) 但是,无法识别Ionic应用程序的域名(当然不是'localhost'或127.0.0.1)

So, my question is: does Firebase signInWithEmailAndPassword(email, password) actually work with Ionic and other web-wrapper platforms, or is this currently unsupported? 所以,我的问题是:Firebase signInWithEmailAndPassword(电子邮件,密码)是否真的与Ionic和其他网络包装平台一起使用,或者目前是否支持?

Make sure you are setting the correct Content-Security-Policy too. 确保您也设置了正确的Content-Security-Policy。 Something along: 一些东西:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' https://* 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://* 'unsafe-inline' 'unsafe-eval'; ">

Many thanks for the responses. 非常感谢您的回复。 For those interested in the solution to this problem, it did not reside with Firebase. 对于那些对此问题的解决方案感兴趣的人来说,它并不存在于Firebase中。 Rather, newer versions of Cordova and Ionic sometimes throw http 404 errors when the app tries to make network requests. 相反,较新版本的Cordova和Ionic有时会在应用程序尝试发出网络请求时抛出http 404错误。

In order to solve these 404 errors, the app needs the Cordova WhiteList plugin added: 为了解决这些404错误,该应用程序需要添加Cordova WhiteList插件:

http://docs.ionic.io/docs/cordova-whitelist http://docs.ionic.io/docs/cordova-whitelist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何捕获Android Firebase signUpWithEmailAndPassword错误代码? - How to catch Android Firebase signUpWithEmailAndPassword error code? 安装 Firebase X 后无法使用cordova 运行Ionic 4 应用程序 - Unable to run Ionic 4 app using cordova after installing Firebase X 使用cordova-plugin-firebase-messaging显示来自Ionic的通知 - Displaying notifications from Ionic using cordova-plugin-firebase-messaging 单击使用离子和Firebase云消息传递的通知后,打开页面 - Open a page after click on notification using ionic and firebase cloud messaging 使用 Firebase 将通知从 WordPress 推送到 Ionic APP - Using Firebase to push notification from WordPress to Ionic APP “ AUTHENTICATION DISABLED”,使用Firebase离子电子邮件/密码身份验证时出错 - “AUTHENTICATION DISABLED”, error using Firebase Ionic Email/Password Authentication 在离子、电容器、angular 上使用 Firebase 性能监控网络请求 - Monitoring network requests using Firebase performance on ionic, capacitor, angular Ionic Firebase登录问题 - Ionic firebase Login issue 具有Ionic 2 Google身份验证的Firebase 3 - Firebase 3 with ionic 2 google authentication Firebase的离子推送 - Ionic push with Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM