Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to reinitialize the default firebase app?

//first call to initialize app
if (!firebase.apps.length) {
  firebase.initializeApp(config)
}

When the user logs out, I need them to disconnect to the realtime database.

firebase.app().delete().then( () => {
 if (!firebase.apps.length) 
 {
    firebase.initializeApp(config)
 }
 this.goToSignin();
})

However, when I try to sign in again I get an error saying the default app is already deleted

FirebaseError: Firebase: Firebase App named '[DEFAULT]' already deleted (app/app-deleted).
like image 592
user492046 Avatar asked Oct 11 '25 20:10

user492046


1 Answers

I don't think you're supposed to ever re-initialize an app of the same name, even if the previous one is deleted. But I'm not entirely sure, so it might be worth to reach out to Firebase support for personalized help in troubleshooting.

In the meantime, I'd recommend generating named app instances, so that you can control their name.

const app = firebase.initializeApp(config, "myname");

You can then pass app around and use that instead of firebase in most places.

like image 90
Frank van Puffelen Avatar answered Oct 14 '25 09:10

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!