Firebase InitializeApp Error


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.


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


try it in app.component.ts

 constructor(platform: Platform,/*public push:Push,  translate: TranslateService,*/public alrtCtl:AlertController) {
  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.



Yes. I tried that actually.


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