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';
angular
.module('mycoolmodule')
.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
app.run(function($ionicPlatform, $ionicPush, FIREBASE_URL) {
$ionicPlatform.ready().then(function(){
var ref = new Firebase(FIREBASE_URL);
ref.child(".info/connected").on("value", function(snap){
if(snap.val() === true){
console.info("Firebase connected")
}else{
console.info("Firebase disconnected");
}
});
});
});
Aaah ok, just like we were doing⦠cool
Hi,
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:
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
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.
Hi,
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.
$scope.$watch(function(){
if(localStorage.getItem(āfirebase:previous_websocket_failureā)!=null)
return localStorage.getItem(āfirebase:previous_websocket_failureā).toString();
},function(newValue, OldValue){
localStorage.removeItem(āfirebase:previous_websocket_failureā);
});
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 , 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!