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

后端 未结 1 378
死守一世寂寞
死守一世寂寞 2021-01-07 09:25

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

1条回答
  •  轮回少年
    2021-01-07 10:15

    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);
    

    0 讨论(0)
提交回复
热议问题