Your desire to create a user configurable client is unusual. You must have some very special requirements. I don't think the type of FCM client configuration you want to do is possible. I'll explain my reasoning.
First, the google-services.json
file is processed at build time, not run time. It is parsed by the Google Services Gradle Plugin, which generates an XML file of string resources at .../app/build/generated/res/google-services/{buildType}/values/values.xml
.
When an app that uses Firebase starts up, the FirebaseInitProvider configures itself using those string resources, and creates the default instance of FirebaseApp. The default FirebaseApp
is used by FirebaseMessaging.getInstance().
Some Firebase APIs, FirebaseDatabase and FirebaseStorage are two examples, provide getInstance()
methods that accept a FirebaseApp
parameter. For these, one can create a custom FirebaseApp
using initializeApp() and FirebaseOptions.Builder to specify the values that are normally provided by google-services.json
. But FirebaseMessaging does not have a getInstance()
that accepts a FirebaseApp
parameter, forcing use of the default FirebaseApp
created using the google-services.json
file.