Closed sroddy closed 6 years ago
Have you tried passing new options together with a unique name
to initializeApp
? It seems like what you are looking for. E.g.:
// Creates an app with default name and options in [config1]
final app1 = FirebaseAdmin.instance.initializeApp(config1);
// Creates another app with options from [config2] and name `unique_string`.
final app2 = FirebaseAdmin.instance.initializeApp(config2, 'unique_string');
no, I didn't. I thought that the app name was the one from the Firebase project and you couldn't arbitrarily use the one you want. I'll give it a try and let you know, Thanks
Here are the official docs on this feature: https://firebase.google.com/docs/admin/setup#initialize_multiple_apps
Well in my case the app is one. I just have different real-time databases...
Hey, sorry I didn't follow up this. Did you manage to resolve this issue?
I'll assume this is fixed for now and close it. Feel free to re-open if more help is needed.
Right now, initializing a FirebaseAdmin instance returns the same cached app even if different initialization options are sent (in my case the database), because the app is cached in a map using its name as key.
Ideally I would need to have multiple instances of different realtime databases and interact with them at the same time.
But in the meanwhile a simple fix to at least be able to re-init the app with a different db would be enough to solve my immediate urgency.
@pulyaevskiy is there anything you can suggest?
Thanks