cordova-plugin-firebasex
cordova-plugin-firebasex copied to clipboard
[FEATURE] Configure multiple projects
Feature request
It'd be good to be able to configure multiple projects. Will need to load different plist/json file.
https://firebase.google.com/docs/projects/multiprojects
I think you can do a little workaround. You can create two files for example in your environment folder, *--dev.json, *--prod.json and use cordova hooks to copy enviroment file before build app.
https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/
or you can add scripts in your package.json :)
As part of our Angular build process, we use asset copy to leave an artifact of the build type for the firebase-config script to check. Ideally there's a cleaner way to do this first step; we wanted to maintain the ability to mix and match QA/Prod while still doing a signed cordova release build.
config.xml
<hook src="scripts/firebase-config.js" type="after_prepare" />
scripts/firebase-config.js
var path = require('path');
var fs = require('fs');
module.exports = function(context) {
var isProd = fs.existsSync(path.join(context.opts.projectRoot, 'www/assets/environment.prod.ts'));
var configSrc;
if (isProd) {
configSrc = ['src/environments/google-services.prod.json', 'src/environments/GoogleService-Info.prod.plist'];
} else {
configSrc = ['src/environments/google-services.qa.json', 'src/environments/GoogleService-Info.qa.plist'];
}
fs.copyFileSync(
path.join(context.opts.projectRoot, configSrc[0]),
path.join(context.opts.projectRoot, 'google-services.json'),
);
fs.copyFileSync(
path.join(context.opts.projectRoot, configSrc[1]),
path.join(context.opts.projectRoot, 'GoogleService-Info.plist'),
);
console.log('firebase-config:', ...configSrc);
return true;
};
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Reopening as stalebot incorrectly closed it