Firebase InitializeApp Error


#1

I had this error for quite a while where my page would load before the “firebase.initializeApp” function. when I put it in platform.ready(()=>({)} still nothing.

My workaround was to set my “rootPage” to a blank page then:

firebase.auth().onAuthStateChanged((user) => {
  if (!user) {
    this.rootPage = LoginPage;
  } else{
    this.rootPage = HomePage;
  }
});

I don’t know why it works but… it does.

Ionic2 R.C. 3&4.


#2

Have you tried placing firebase.initializeApp in the constructor for AppModule? That works in my experience.


#3

try it in app.component.ts

 constructor(platform: Platform,/*public push:Push,  translate: TranslateService,*/public alrtCtl:AlertController) {
     firebase.initializeApp({
  apiKey: "",
    authDomain: "",
    databaseURL: "",
    storageBucket: "",
    messagingSenderId: ""
 
});
     platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();

         
 
    
    });

#4

Yes. I tried that actually.


#5

I… had not thought of that… wow… I mean, It makes sense but why didnt I think of that…