it's possible to create an android application(related to Firebase) which provides to every user the ability to connect to his own firebase , without sharing his information with other users( not the collaboration method ,generally, the app is about to track object : the user connect to app , get the object information and store it in his account and than track it) .. so any solution for the login process ?
-
Do you mean to say having a custom object inside firebase user Object? – erluxman Aug 23 '19 at 01:06
-
@erluxman no not that the problem , all i need is to find a way that the application could connect to different users console( for example mine, yours ,and other users ) independently ( the issue is that the app is related to a project which is under a console one person (the owner) ) , okay ? – badii mrad Aug 23 '19 at 02:15
1 Answers
Which backend resources your Android code connects to is determined by the FirebaseApp instance. The default app is usually initialized from the google-services.json that you add to your project, so can't be dynamically changed from within the code.
But you can also initialize a FirebaseApp instance from within your Android code. All you need is the pertinent information from the Firebase project of the user, which would otherwise be read from their google-services.json. You'll want to build a FirebaseOptions object in that case, which contains things like the Application ID, Project ID, Database URL and a few more values.
Once you have a FirebaseApp, you can then get the other Firebase services from that. It's quite similar to my answer on accessing multiple databases in a single app from a few years ago. From there:
FirebaseOptions options = new FirebaseOptions.Builder() .setApiKey("AI...j0") .setApplicationId("1:5...e0") .setDatabaseUrl("https://myapp.firebaseio.com") .build(); FirebaseApp secondApp = FirebaseApp.initializeApp(getApplicationContext(), options, "second app"); FirebaseDatabase secondDatabase = FirebaseDatabase.getInstance(secondApp); secondDatabase.getReference().setValue(ServerValue.TIMESTAMP);
- 565,676
- 79
- 828
- 807