cordova-plugin-firebase
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -23,2 +23,5 @@ --- | ||
**Plugin Version** | ||
Run `cordova plugin list` to find out what version of cordova-plugin-firebase you are running with | ||
**Desktop (please complete the following information):** | ||
@@ -25,0 +28,0 @@ - OS: [e.g. iOS] |
# Version 2.0.1 | ||
## Bug Fixes | ||
### Bug Fixes | ||
- <a href="https://github.com/arnesson/cordova-plugin-firebase/pull/836">#836</a>: Fixed Crashlytics on iOS | ||
@@ -9,6 +9,6 @@ - <a href="https://github.com/arnesson/cordova-plugin-firebase/pull/830">#830</a>: Fixed initialization of firebase services | ||
## Features | ||
### Features | ||
- <a href="https://github.com/arnesson/cordova-plugin-firebase/issues/796">#796</a>: Update Firebase SDK Version to 5.x | ||
## Bug Fixes | ||
### Bug Fixes | ||
- <a href="https://github.com/arnesson/cordova-plugin-firebase/issues/822">#822</a>: Can't use initFirebase() on 1.1.3 [Firebase isn't initialized] | ||
@@ -15,0 +15,0 @@ - <a href="https://github.com/arnesson/cordova-plugin-firebase/issues/827">#827</a>: doc missing: initFirebase call needed before anything |
@@ -44,2 +44,4 @@ # Contribution Guidelines | ||
MAKE SURE THE CODE WORKS WITHOUT MODIFYING OR CHECKING IN ANY PLATFORM FILES. Any changes to platform files (like build scripts, config files or anything in the /platform directory) should be made by the plugin. Since Cordova 4.3.0, the [platform management feature](https://cordova.apache.org/docs/en/latest/platform_plugin_versioning_ref/) allows you to build your project without checking in any platform files. | ||
# Pull Requests | ||
@@ -46,0 +48,0 @@ |
@@ -11,3 +11,3 @@ { | ||
"name": "cordova-plugin-firebase", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Cordova plugin for Google Firebase", | ||
@@ -14,0 +14,0 @@ "cordova": { |
@@ -1,3 +0,1 @@ | ||
# Cordova-Plugin-Firebase version (run 'cordova plugin list' to get this information) | ||
# Tell us what's troubling you | ||
# TODO |
[![Build Status](https://travis-ci.org/arnesson/cordova-plugin-firebase.svg?branch=master)](https://travis-ci.org/arnesson/cordova-plugin-firebase) | ||
# cordova-plugin-firebase | ||
This plugin brings push notifications, analytics, event tracking, crash reporting and more from Google Firebase to your Cordova project! | ||
Android and iOS supported. | ||
This plugin brings push notifications, analytics, event tracking, crash reporting and more from Google Firebase to your Cordova project! Android and iOS supported. | ||
Donations are welcome and will go towards further development of this project. Use the addresses below to donate. | ||
``` | ||
BTC: 1JuXhHMCPHXT2fDfSRUTef9TpE2D67sc9f | ||
ETH: 0x74B5eDEce465fDd360b3b03C6984784140ac742e | ||
BCH: qzu5ffphkcgajn7kd7d90etq82maylz34uqg4uj5jf | ||
LTC: LKnFugRfczVH7qfBrmhzZDknhqxCzz6wJB | ||
XMR: 43ZMMEh5x4miZLMZF3W3faAL5Y44fPBXrFWBVXYePBjwXCvxLuo84Cof8ufXgb4sZLEpSDE3eKr5X7jNPfd4kppr8oMX9uM | ||
Paypal: https://paypal.me/arnesson | ||
``` | ||
Thank you for your support! | ||
## Supported Cordova Versions | ||
@@ -39,3 +25,3 @@ - cordova: `>= 6` | ||
### Setup | ||
Download your Firebase configuration files, GoogleService-Info.plist for ios and google-services.json for android, and place them in the root folder of your cordova project. Check out this [firebase article](https://support.google.com/firebase/answer/7015592) for details on how to download the files. | ||
Download your Firebase configuration files, GoogleService-Info.plist for iOS and google-services.json for android, and place them in the root folder of your cordova project. Check out this [firebase article](https://support.google.com/firebase/answer/7015592) for details on how to download the files. | ||
@@ -53,3 +39,3 @@ ``` | ||
#### IMPORTANT NOTES | ||
###### IMPORTANT NOTES | ||
- 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. | ||
@@ -56,0 +42,0 @@ - Firebase SDK requires the configuration files to be present and valid, otherwise your app will crash on boot or Firebase features won't work. |
@@ -13,4 +13,4 @@ | ||
if (platforms.indexOf("android") !== -1) { | ||
androidHelper.removeFabricBuildToolsFromGradle(); | ||
androidHelper.addFabricBuildToolsGradle(); | ||
androidHelper.restoreRootBuildGradle(); | ||
androidHelper.modifyRootBuildGradle(); | ||
} | ||
@@ -17,0 +17,0 @@ |
@@ -54,29 +54,6 @@ #!/usr/bin/env node | ||
], | ||
stringsXml: fileExists(ANDROID_DIR + '/app/src/main/res/values/strings.xml') ? ANDROID_DIR + '/app/src/main/res/values/strings.xml' : ANDROID_DIR + '/res/values/strings.xml' | ||
} | ||
}; | ||
function updateStringsXml(contents) { | ||
var json = JSON.parse(contents); | ||
var strings = fs.readFileSync(PLATFORM.ANDROID.stringsXml).toString(); | ||
// replace the value | ||
strings = strings.replace(new RegExp('<string name="google_app_id">([^<]+?)</string>', 'i'), '<string name="google_app_id">' + json.client[0].client_info.mobilesdk_app_id + '</string>'); | ||
// replace the value | ||
strings = strings.replace(new RegExp('<string name="google_api_key">([^<]+?)</string>', 'i'), '<string name="google_api_key">' + json.client[0].api_key[0].current_key + '</string>'); | ||
// strip default value if still present | ||
strings = strings.replace(new RegExp('<string name="google_app_id">\@([^<]+?)</string>', 'i'), ''); | ||
// strip default value if still present | ||
strings = strings.replace(new RegExp('<string name="google_api_key">\@([^<]+?)</string>', 'i'), ''); | ||
// strip empty lines | ||
strings = strings.replace(new RegExp('(\r\n|\n|\r)[ \t]*(\r\n|\n|\r)', 'gm'), '$1'); | ||
fs.writeFileSync(PLATFORM.ANDROID.stringsXml, strings); | ||
} | ||
function copyKey (platform, callback) { | ||
function copyKey (platform) { | ||
for (var i = 0; i < platform.src.length; i++) { | ||
@@ -97,4 +74,2 @@ var file = platform.src[i]; | ||
} | ||
callback && callback(contents); | ||
} catch (err) { | ||
@@ -144,4 +119,4 @@ console.log(err); | ||
console.log('Preparing Firebase on Android'); | ||
copyKey(PLATFORM.ANDROID, updateStringsXml); | ||
copyKey(PLATFORM.ANDROID); | ||
} | ||
}; |
@@ -12,3 +12,3 @@ | ||
if (platforms.indexOf("android") !== -1) { | ||
androidHelper.removeFabricBuildToolsFromGradle(); | ||
androidHelper.restoreRootBuildGradle(); | ||
} | ||
@@ -15,0 +15,0 @@ |
var fs = require("fs"); | ||
var path = require("path"); | ||
var utilities = require("./utilities"); | ||
function rootBuildGradleExists() { | ||
var target = path.join("platforms", "android", "build.gradle"); | ||
return fs.existsSync(target); | ||
} | ||
/* | ||
* Helper function to read the build.gradle that sits at the root of the project | ||
*/ | ||
function readRootBuildGradle() { | ||
var target = path.join("platforms", "android", "build.gradle"); | ||
return fs.readFileSync(target, "utf-8"); | ||
} | ||
/* | ||
* Added a dependency on 'com.google.gms' based on the position of the know 'com.android.tools.build' dependency in the build.gradle | ||
*/ | ||
function addDependencies(buildGradle) { | ||
// find the known line to match | ||
var match = buildGradle.match(/^(\s*)classpath 'com.android.tools.build(.*)/m); | ||
var whitespace = match[1]; | ||
// modify the line to add the necessary dependencies | ||
var googlePlayDependency = whitespace + 'classpath \'com.google.gms:google-services:4.1.0\' // google-services dependency from cordova-plugin-firebase'; | ||
var fabricDependency = whitespace + 'classpath \'io.fabric.tools:gradle:1.25.4\' // fabric dependency from cordova-plugin-firebase' | ||
var modifiedLine = match[0] + '\n' + googlePlayDependency + '\n' + fabricDependency; | ||
// modify the actual line | ||
return buildGradle.replace(/^(\s*)classpath 'com.android.tools.build(.*)/m, modifiedLine); | ||
} | ||
/* | ||
* Add 'google()' to the repository repo list | ||
*/ | ||
function addRepos(buildGradle) { | ||
// find the known line to match | ||
var match = buildGradle.match(/^(\s*)jcenter\(\)/m); | ||
var whitespace = match[1]; | ||
// modify the line to add the necessary repo | ||
var googlesMavenRepo = whitespace + 'google() // Google\'s Maven repository from cordova-plugin-firebase'; | ||
var fabricMavenRepo = whitespace + 'maven { url \'https://maven.fabric.io/public\' } // Fabrics Maven repository from cordova-plugin-firebase' | ||
var modifiedLine = match[0] + '\n' + googlesMavenRepo + '\n' + fabricMavenRepo; | ||
// modify the actual line | ||
return buildGradle.replace(/^(\s*)jcenter\(\)/m, modifiedLine); | ||
} | ||
/* | ||
* Helper function to write to the build.gradle that sits at the root of the project | ||
*/ | ||
function writeRootBuildGradle(contents) { | ||
var target = path.join("platforms", "android", "build.gradle"); | ||
fs.writeFileSync(target, contents); | ||
} | ||
module.exports = { | ||
addFabricBuildToolsGradle: function () { | ||
modifyRootBuildGradle: function() { | ||
// be defensive and don't crash if the file doesn't exist | ||
if (!rootBuildGradleExists) { | ||
return; | ||
} | ||
var buildGradle = utilities.readBuildGradle(); | ||
var buildGradle = readRootBuildGradle(); | ||
var addToBuildGradle = [ | ||
"", | ||
"// Fabric Cordova Plugin - Start Fabric Build Tools ", | ||
"buildscript {", | ||
" repositories {", | ||
" maven { url 'https://maven.fabric.io/public' }", | ||
" maven { url 'https://maven.google.com' }", | ||
" }", | ||
" dependencies {", | ||
" classpath 'io.fabric.tools:gradle:1.25.4'", | ||
" classpath 'com.google.gms:google-services:+'", | ||
" }", | ||
"}", | ||
"", | ||
"apply plugin: 'io.fabric'", | ||
"apply plugin: 'com.google.gms.google-services'", | ||
"// Fabric Cordova Plugin - End Fabric Build Tools" | ||
].join("\n"); | ||
// Add Google Play Services Dependency | ||
buildGradle = addDependencies(buildGradle); | ||
// Add Google's Maven Repo | ||
buildGradle = addRepos(buildGradle); | ||
buildGradle = buildGradle.replace(/(\/\/ PLUGIN GRADLE EXTENSIONS START)/, addToBuildGradle + '\n\n$1'); | ||
utilities.writeBuildGradle(buildGradle); | ||
writeRootBuildGradle(buildGradle); | ||
}, | ||
removeFabricBuildToolsFromGradle: function () { | ||
restoreRootBuildGradle: function() { | ||
// be defensive and don't crash if the file doesn't exist | ||
if (!rootBuildGradleExists) { | ||
return; | ||
} | ||
var buildGradle = utilities.readBuildGradle(); | ||
var buildGradle = readRootBuildGradle(); | ||
buildGradle = buildGradle.replace(/\n\/\/ Fabric Cordova Plugin - Start Fabric Build Tools[\s\S]*\/\/ Fabric Cordova Plugin - End Fabric Build Tools/, ""); | ||
utilities.writeBuildGradle(buildGradle); | ||
// remove any lines we added | ||
buildGradle = buildGradle.replace(/(?:^|\r?\n)(.*)cordova-plugin-firebase*?(?=$|\r?\n)/g, ''); | ||
writeRootBuildGradle(buildGradle); | ||
} | ||
}; |
@@ -6,18 +6,3 @@ /** | ||
var path = require("path"); | ||
var fs = require("fs"); | ||
/** | ||
* Used to get the path to the build.gradle file for the Android project. | ||
* | ||
* @returns {string} The path to the build.gradle file. | ||
*/ | ||
function getBuildGradlePath () { | ||
var target = path.join("platforms", "android", "app", "build.gradle"); | ||
if (fs.existsSync(target)) { | ||
return target; | ||
} | ||
return path.join("platforms", "android", "build.gradle"); | ||
} | ||
module.exports = { | ||
@@ -57,20 +42,2 @@ | ||
/** | ||
* Used to read the contents of the Android project's build.gradle file. | ||
* | ||
* @returns {string} The contents of the Android project's build.gradle file. | ||
*/ | ||
readBuildGradle: function () { | ||
return fs.readFileSync(getBuildGradlePath(), "utf-8"); | ||
}, | ||
/** | ||
* Used to write the given build.gradle contents to the Android project's | ||
* build.gradle file. | ||
* | ||
* @param {string} buildGradle The body of the build.gradle file to write. | ||
*/ | ||
writeBuildGradle: function (buildGradle) { | ||
fs.writeFileSync(getBuildGradlePath(), buildGradle); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4
98465461
647
61