Is it possible to connect to a Firebase Database to a different Firebase Project?

落爺英雄遲暮 提交于 2019-12-30 07:44:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!