mk-5 / gdx-fireapp

libGDX Firebase API
Apache License 2.0
63 stars 21 forks source link

Support for multiple realtime databases #51

Closed edosam closed 3 years ago

edosam commented 3 years ago

Problem: There is a real need to connect to multiple (different) realtime databases for bigger projects. For example, there is one database for Android users and one for iOS users.

Solution: It would be nice if there is a method like this: GdxFIRDatabase.inst(String dbUrl);

Firebase doc: https://firebase.google.com/docs/database/usage/sharding

mk-5 commented 3 years ago

@edosam hello there!

good point. It should be easy to modify. I will pick it up

mk-5 commented 3 years ago

@edosam hello again

so, the feature is ready to be merged and deploy. There is one problem: jcenter is dead.

I need to find some alternative. Maven-central deployments are pain in the ass

mk-5 commented 3 years ago

@edosam okay, I decided to use mavenCentral for now.

The new version 3.1.0 is deployed. It should be available in maven-central search within ~2 hours. Please let me know if that works for you.

The multiple-database feature works exactly as you proposed. There is a new method:

GdxFIRDatabase.inst(String dbUrl)

Wiki page with example: https://github.com/mk-5/gdx-fireapp/wiki/Database-sharding

mk-5 commented 3 years ago

@edosam I'm closing this issue. Feel free to re-open it in case of any issues with multi-databases solution

edosam commented 3 years ago

Hello @mk-5 Thank you for implementing this feature. It's working correctly on Android device, but app is still connecting to base database on iOS. Is there some other configuration required for iOS? Or it isn't just implemented for iOS?

mk-5 commented 3 years ago

@edosam it should work on ios as well. I need to check it

mk-5 commented 3 years ago

@edosam I checked, and it looks good 🤔

could you send me an info about which DB action is causing this problem?

by the way, in order to use different database for iOS/Android, you can also add different DATABASE_URL in your GoogleService-info.plist like this:

    <key>DATABASE_URL</key>
    <string>https://diffrent-url-for-ios.firebaseio.com</string>