pulyaevskiy / firebase-admin-interop

Firebase Admin Interop Library for Dart
BSD 3-Clause "New" or "Revised" License
79 stars 37 forks source link

Unable to change Firebase Realtime Database URL after initialization #28

Closed sroddy closed 6 years ago

sroddy commented 6 years ago

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

pulyaevskiy commented 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'); 
sroddy commented 6 years ago

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

pulyaevskiy commented 6 years ago

Here are the official docs on this feature: https://firebase.google.com/docs/admin/setup#initialize_multiple_apps

sroddy commented 6 years ago

Well in my case the app is one. I just have different real-time databases...

pulyaevskiy commented 6 years ago

Hey, sorry I didn't follow up this. Did you manage to resolve this issue?

pulyaevskiy commented 6 years ago

I'll assume this is fixed for now and close it. Feel free to re-open if more help is needed.