I'm building an app that has an arbitrary amount of 'micro-communities' on it. Currently a user can only belong to one, so when they initially sign up, they enter a secret code which associates them with the relevant community.
Is it wise to separate these 'micro-communities' (which are owned by future clients playing for a space on the app) into separate Firebase projects or keep all the data together?
Firebase now supports accessing multiple projects in one app. No need to go the micro-community route. Here is the tutorial on how to do it: https://firebase.google.com/docs/configure/
I'm currently using it in my project in Android, so if you are having trouble setting it up and are implementing it in Android, feel free to drop a comment!
EDIT
When you configure Firebase with your app you are defaulted to one database account. If you would like to use a second one (or more), continue reading.
In your activity or fragment, you must initialize a FirebaseOptions instance with all your account info, initialize a FirebaseApp with a tag name that represents the second account, then get the instance of your FirebaseApp, and lastly, get a DatabaseReference instance of your second account so you may use it as you like. Here is the block of code I use: (NOTE: the information you enter as the parameters for you FirebaseOptions instance is associated with your SECOND database account):
private void initSecondFirebaseAcct()
{
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("<your application id>")
.setApiKey("<your api key>")
.setDatabaseUrl("<your DB url that ends in 'firebaseio.com/' ")
.build();
try
{
FirebaseApp.initializeApp(this, options, "<database tag>");
}
catch (Exception e)
{
Log.d("Firebase error", "App already exists");
}
mMySecondApp = FirebaseApp.getInstance("<database tag>");
mSecondDBRef = FirebaseDatabase.getInstance(mMySecondApp).getReference();
}
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With