gautam
gautam

Reputation: 1851

How to connect multiple apps to firestore database

I want to add multiple apps to one firestore database but couldn't find any working solution to it for me .

The one way is to add all apps to firebase project but its very difficult for me as the apps are already on other projects .

In realtime database you can do like this:-

val secondary = FirebaseDatabase
    .getInstance("https://testapp-1234.firebaseio.com").reference

from the docs:- https://firebase.google.com/docs/database/usage/sharding

But its not there in firestore . If anyone know please help .

Upvotes: 2

Views: 670

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317437

You will need to initialize a new FirebaseApp instance and configure it to point to your other project, and do this once for each project.

FirebaseApp app = FirebaseApp.initializeApp(...);

You then use this new FirebaseApp object to reach into their instances of Firestore using FirebaseFirestore.getInstance():

FirebaseFirestore firestore = FirebaseFirestore.getInstance(app);

This new FirebaseFirestore object will operate against the project configured in the FirebaseApp object.

Upvotes: 3

Related Questions