是否可以将Firebase数据库连接到不同的Firebase项目? [英] Is it possible to connect to a Firebase Database to a different Firebase Project?
问题描述
所以我在想如果我可以在应用程序A中创建一个消息表,并从应用程序B访问相同的消息,并实现我的消息功能。可以这样做吗?如果是,请给我一些信息?如果没有一个替代方案?
谢谢
能够通过显式提供配置数据访问其他数据库:
FirebaseOptions options = new FirebaseOptions.Builder()
.setApiKey(AI ... j0)
.setApplicationId(1:5 ... e0)//我不确定这是否需要
.setDatabaseUrl(https ://myapp.firebaseio.com)
.build();
FirebaseApp app = FirebaseApp.initializeApp(getApplicationContext(),options,app);
FirebaseDatabase数据库= FirebaseDatabase.getInstance(app);
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
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);
这篇关于是否可以将Firebase数据库连接到不同的Firebase项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!