I have a Cordova/ionic/angular app that uses Firebase auth and works perfectly in a browser and in an emulator. On a real device, however, calls to firebase.auth() return error-code "auth/network-request-failed", indicating that a network error (such as timeout, interrupted connection or unreachable host) has occurred. This occurs when I run device-debug from, in my case, Visual Studio but also when I install the app on a device (Android phone) and simply run it.
The firebase code is:
<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
I have already replaced the <form> stuff with simple <div>s in the template because I read here that it could cause a re-submit which triggers the network error. I have tried the button both with a <button> directive and with the <a> directive. No difference. Unless angular or ionic do some magic that messes up the directives, this ought to be clean but you never know.
The following security meta-tag is also included as it was posted here as a possible solution to the problem:
<meta "content_security_policy":"script-src 'self' https://apis.google.com https://www.googleapis.com https://securetoken.googleapis.com; object-src 'self'" , "permissions": [ "https://*/*", "activeTab" ] >
The js code shouldn't be the issue as the app is working fine in a browser but I am including it anyway:
firebase.auth().signInWithEmailAndPassword(email, password)
.then(() => { ... }
.catch(error => {
console.log(error.code, error.message);
});
Lastly, I have an onAuthStateChanged observer attached. The observer does get initialized on the device but it never fires - of course - because the auth() call returns an error.
What am I doing wrong? Any help is highly appreciated.