diff --git a/plugin.xml b/plugin.xml
index e1c2c8959..0d81d9ec0 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -20,12 +20,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
-
- @string/google_app_id
-
-
- @string/google_api_key
-
@@ -47,7 +41,6 @@ xmlns:android="http://schemas.android.com/apk/res/android">
-
@@ -55,13 +48,13 @@ xmlns:android="http://schemas.android.com/apk/res/android">
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -81,7 +74,7 @@ xmlns:android="http://schemas.android.com/apk/res/android">
production
-
+
@@ -115,4 +108,5 @@ xmlns:android="http://schemas.android.com/apk/res/android">
+
diff --git a/scripts/after_plugin_install.js b/scripts/after_plugin_install.js
new file mode 100644
index 000000000..ec6ed1e04
--- /dev/null
+++ b/scripts/after_plugin_install.js
@@ -0,0 +1,21 @@
+#!/usr/bin/env node
+'use strict';
+
+var fs = require('fs');
+
+function directoryExists(path) {
+ try {
+ return fs.statSync(path).isDirectory();
+ } catch (e) {
+ return false;
+ }
+}
+
+if (directoryExists('platforms/ios')) {
+ fs.unlinkSync('./plugins/cordova-plugin-firebase/src/ios/GoogleService-Info.plist');
+
+ fs.writeFileSync('./plugins/cordova-plugin-firebase/src/ios/GoogleService-Info.plist', fs.readFileSync('./GoogleService-Info.plist'));
+}
+module.exports = function (context) {
+ require('./after_prepare')(context);
+};
diff --git a/scripts/after_prepare.js b/scripts/after_prepare.js
index d56f05646..96c3093b8 100755
--- a/scripts/after_prepare.js
+++ b/scripts/after_prepare.js
@@ -56,20 +56,16 @@ function updateStringsXml(contents) {
var json = JSON.parse(contents);
var strings = fs.readFileSync(PLATFORM.ANDROID.stringsXml).toString();
- // strip non-default value
- strings = strings.replace(new RegExp('([^\@<]+?)', 'i'), '');
-
- // strip non-default value
- strings = strings.replace(new RegExp('([^\@<]+?)', 'i'), '');
-
// strip empty lines
strings = strings.replace(new RegExp('(\r\n|\n|\r)[ \t]*(\r\n|\n|\r)', 'gm'), '$1');
- // replace the default value
- strings = strings.replace(new RegExp('([^<]+?)', 'i'), '' + json.client[0].client_info.mobilesdk_app_id + '');
-
- // replace the default value
- strings = strings.replace(new RegExp('([^<]+?)', 'i'), '' + json.client[0].api_key[0].current_key + '');
+ // after_prepare is run multiple times, and duplicate strings causes a build error
+ if (~strings.indexOf('google_app_id')) {
+ return;
+ }
+
+ // insert values from json
+ strings = strings.replace('', '' + json.client[0].client_info.mobilesdk_app_id + '' + json.client[0].api_key[0].current_key + '');
fs.writeFileSync(PLATFORM.ANDROID.stringsXml, strings);
}
@@ -128,14 +124,14 @@ function directoryExists(path) {
module.exports = function(context) {
//get platform from the context supplied by cordova
- var platforms = context.opts.platforms;
+ var platforms = context.opts.platforms || context.opts.cordova.platforms;
// Copy key files to their platform specific folders
if (platforms.indexOf('ios') !== -1 && directoryExists(IOS_DIR)) {
- console.log('Preparing Firebase on iOS');
- copyKey(PLATFORM.IOS);
+ //console.log('Preparing Firebase on iOS');
+ //copyKey(PLATFORM.IOS);
}
if (platforms.indexOf('android') !== -1 && directoryExists(ANDROID_DIR)) {
console.log('Preparing Firebase on Android');
copyKey(PLATFORM.ANDROID, updateStringsXml)
}
-};
\ No newline at end of file
+};