问题
I have two android apps (A and B) and both have separate projects on Firebase, Currently I am working on a feature which would lets me send messages between app A and app B using FCM. Due to both apps being in different projects, I am unable to do this and It is not possible to put both the apps on a single project due to some other reason.
So I was thinking if I could create a messages table in app A and access the same from app B and implement my messaging feature. Is it possible to do this? if yes, can you please give me some info? if no is there an alternative?
thanks
回答1:
You should be able to access the "other" database by explicitly providing the configuration data:
FirebaseOptions options = new FirebaseOptions.Builder()
.setApiKey("AI...j0")
.setApplicationId("1:5...e0") // I'm not certain this is needed
.setDatabaseUrl("https://myapp.firebaseio.com")
.build();
FirebaseApp app = FirebaseApp.initializeApp(getApplicationContext(), options, "app");
FirebaseDatabase database = FirebaseDatabase.getInstance(app);
来源:https://stackoverflow.com/questions/39366056/is-it-possible-to-connect-to-a-firebase-database-to-a-different-firebase-project