Created
September 9, 2019 21:03
-
-
Save katowulf/298f5bc5ac164bf4284cf469bce5d732 to your computer and use it in GitHub Desktop.
Get multiple app instances of Firestore in Firebase SDKs. More on multiple environments here: https://firebase.google.com/docs/projects/multiprojects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FirebaseApp primary = FirebaseApp.getInstance(); | |
FirebaseFirestore primaryDatabase = FirebaseFirestore.getInstance(); | |
// Reference the same setup/instance | |
FirebaseOptions options = primary.getOptions(); | |
/* | |
// Use multiple projects/environments. More here: https://firebase.google.com/docs/projects/multiprojects | |
FirebaseOptions options = new FirebaseOptions.Builder() | |
.setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics. | |
.setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth. | |
.setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB. | |
.build(); | |
*/ | |
// Initialize with secondary app. | |
FirebaseApp.initializeApp(this /* Context */, options, "secondary"); | |
// Retrieve secondary app. | |
FirebaseApp secondary = FirebaseApp.getInstance("secondary"); | |
// Get the database for the other app. | |
FirebaseFirestore secondaryDatabase = FirebaseFirestore.getInstance(secondary); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TBD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment