arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1.01k stars 1.56k forks source link

Multiple Firebase Projects #791

Open bloigge opened 6 years ago

bloigge commented 6 years ago

Hi,

This is more a question than an issue. We are using this plugin in an Ionic Project. During the login phase in our app some privileged user can decide if they would like to use the development (testing) or production server. We started using firebase / firestore as a second backend for offline data and messaging, so we created a firebase project for development and production. The problem we face now is that we can only have one google-services.json / GoogleService-Info.plist in the root directory and that @ionic-native/firebase needs to be in the providers array in the the app.module.ts.

Is there by any chance a possiblity to change they google-service.json after the users decided to use the development or production enviroment (the respective firebase project)? Or is it possible to initialize the plugin afterwards and change the path which google-service.json should be used.

But I guess this plugin uses a hook (after prepare) that copies the configuration files to the right place, namely platforms/ios/\<My Project\>/Resources for ios and platforms/android for android will make it hard to do this after the apk or ios project is already build.

briantq commented 6 years ago

Reading Firebase's documentation it does appear to be possible. See https://firebase.google.com/docs/configure/ (under Supporting Different Environments). It seems that you will need to customize the prepare script to handle 2 different configurations, then customize the locations of the files and then modify the native code to dynamically choose the right one.

I don't know @arnesson, but I would imagine that based on the amount of work and customization, if you created a pull request that would go a long way to getting the feature incorporated.

soumak77 commented 6 years ago

@briantq @bloigge yes, a PR is gladly welcomed to resolve this

teslavitas commented 4 years ago

Has anyone managed to set up separate Firebase projects for each environment? Is there a guide how to do it? I have read the Google's document https://firebase.google.com/docs/configure/ , but it describes settings things in XCode and Android projects, which is done by cordova by default.