Reputation: 369
I'm trying to build a library allows users to receive Firebase notifications from our server, while still allowing any third-party developer to set and receive their own Firebase notifications.
I'm struggling with how to do this, especially on the console side. I know you have to register your app's applicationID (project name) with the Firebase and then you receive a google-services.json file to add to your app. How does this work with multiple apps with a different package name for each? In my Firebase console, am I continuously adding the project name of each app that uses my library. That doesn't seem right. And how does the google-services.json file handle multiple senders, and which sender generates it?
I'd appreciate any insight from someone with experience in this area.
Upvotes: 2
Views: 674
Reputation: 317467
What you're trying to do is not generally supported by Firebase. The only supported use is at the application level, not for reuse by other libraries.
That said, some of the features can be used this way if you're willing to initialize them directly in code rather than using the google services Gradle plugin. For example Realtime Database can be programmatically initialized by calling FirebaseDatabase.getInstance(), and you make sure that you're also initializing a dedicated FirebaseApp object to pass to it.
Each Firebase feature has its own static initializer like this. However, if it requires a Context parameter (as with Analytics and Remote Config), you won't really be able to use it safely from a library, because it has no way to separate usage between different components within the app.
For more details, also read:
Upvotes: 3