Ionic / firebase stuck loading forever

This issue has bugged me the most. I have found a potential solution for this problem now which fixed it for me.
1- Do not uncomment cordova.js
2 - wrap every firebase init with ionic paltform ready.
Firebase stays connected as long as the app is open in device.

Hi timmy, could you provide some sample code. How are you wrapping the initialization? We have a factory and we’re not sure how to init firebase properly… would something like this work?

(function() {
	'use strict';

		.factory('Auth', Auth);

	/* @ngInject */
	function Auth(FIREBASE_URL, $firebaseAuth) {
		return $q(function(resolve, reject) {
			$ionicPlatform.ready(function() {
		           var ref = new Firebase(FIREBASE_URL);
                           resolve( $firebaseAuth(ref) );

You can use this solution - I asked this on stackoverflow . received an answer from firebase team - Interesting use of $q(Constructor)

Also you can monitor your connection by listening on firebase at .info/connected - like this$ionicPlatform, $ionicPush, FIREBASE_URL) {

var ref = new Firebase(FIREBASE_URL);
ref.child(".info/connected").on("value", function(snap){
  if(snap.val() === true){"Firebase connected")
  }else{"Firebase disconnected");


1 Like

Aaah ok, just like we were doing… cool


I’m experiencing the same issue on Ionic 2

Cordova CLI: 5.4.1
Ionic Version: 2.0.0-alpha.57
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: 1.8.3
ios-sim version: 5.0.1
OS: Mac OS X El Capitan
Node Version: v5.1.1
Xcode version: Xcode 7.2 Build version 7C68

any ideas to resolve this issue? I can’t believe that I’m alone with issue. I’ve added an issue ticket for this:

1 Like

THANK YOU!!! After upgrading to Cordova 6 and the latest cordova-ios, I started seeing this strange behavior. Wrapping my firebase calls up like this works great – I should have been doing that to begin with, I am guessing.

Had the same problem (firebase stuck on loading and released on pressing back button) and it was resolved by putting the following meta on my

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *">

To notice, if you use ionic platform web client, you shouldn’t uncomment cordova.js on your index

1 Like

Hello Parvezd Where you able to programatically set the “firebase:previous_websocket_failure” if yes please drop a sample code thanks Because this Firebase issue with Ionic is annoying.


The “firebase:previous_websocket_failure” key is a local storage variable that firebase uses. So i used this code snippet to resolve the issue and after this I have not encountered the problem again.

return localStorage.getItem(“firebase:previous_websocket_failure”).toString();
},function(newValue, OldValue){

Thanks Parvezd for this i will give it a try But where did you place the code ? in app.js or controller ?

I had this problem as well. The solution for me was to move all of my Firebase initialization code from my tag to $ionicPlatform.ready() instead.

I’m on ionic 5 and facing the same issue. The only problem is that there is no cordova.js in index.html anymore?

I have capacitor 3, and it´s not working :frowning:, always loading after I pick up google email

When you necromance a five-year-old thread, it’s a pretty safe bet that your code has virtually nothing in common with any of the previous participants. Therefore if you expect anybody to have a prayer of helping you, you need to provide enough information for somebody to be able to replicate your problem.

Just followed this link How to add Capacitor Google Sign In to your Ionic App - YouTube, and it’s not working.
Thank you for the reply!