Parameters Firebase bank

Asked

Viewed 42 times

0

The flutter has to communicate with firebase the file google-services.json, would have some way to send parameters with the key of another firebase database and projectid?

1 answer

0


It is possible to do what you want, but anyway you would have to have a . json default file. To connect to another database you would have to create another instance of FirebaseApp and configure it as you wish:

FirebaseDatabase database = FirebaseDatabase.getInstance();
FirebaseOptions options = new FirebaseOptions.Builder()
       .setApplicationId("1:530266078999:android:481c4ecf3253701e") // Requirido para o Analytics.
       .setApiKey("AIzaSyBRxOyIj5dJkKgAVPXRLYFkdZwh2Xxq51k") // Requirido para o Auth.
       .setDatabaseUrl("https://project-1765055333176374514.firebaseio.com/") // Required for RTDB.
       .build();
FirebaseApp.initializeApp(this /* Context */, options, "secundaria");

And to access this new instance just specify the same at the time of declaring your connection

FirebaseApp app = FirebaseApp.getInstance("secundaria");
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(app);

Normally we don’t need to set anything up manually because the firebase’s browser already does everything for us, searching the data in the google-services.js configuration file. In case then you would have the default connection, which comes from the configuration file, and to connect to other databases you would make the connection manually at runtime dynamically.

Source: The Firebase Blog

I don’t have access to Flutter right now and I didn’t actually test that method, but it seems to be kind of simple.

Is there this other question in the English OS that can help you with something too

This is an answer I formulated to this question but there has been no feedback from the user and as your question is very similar to his, I believe it serves for you...

  • 1

    opa thanks already gave a light with that answer already I can make a test.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.