-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move from Firebase Crash to Firebase Crashlytics and stop opt-in users #784
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
48fec65
move from firebase crash to crashlytics - OK for Android
gvieduc d648c1b
equivalent sur ios
gvieduc bb102c9
VSCode configuration file haven't to be versioned
gvieduc 06a8b2d
Bubble notification to the app when in foreground
gvieduc 49658c4
Merge branch 'master' of https://github.com/gvieduc/cordova-plugin-fi…
gvieduc e024028
Getting back on notification initialisation
gvieduc 4e67ea9
Weird assert deletionc
gvieduc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
.build-browser | ||
package-lock.json | ||
node_modules | ||
cordova-plugin-firebase.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
var androidHelper = require('./lib/android-helper'); | ||
var iosHelper = require("./lib/ios-helper"); | ||
var utilities = require("./lib/utilities"); | ||
|
||
module.exports = function(context) { | ||
|
||
var platforms = context.opts.cordova.platforms; | ||
|
||
// Modify the Gradle build file to add a task that will upload the debug symbols | ||
// at build time. | ||
if (platforms.indexOf("android") !== -1) { | ||
androidHelper.removeFabricBuildToolsFromGradle(); | ||
androidHelper.addFabricBuildToolsGradle(); | ||
} | ||
|
||
// Add a build phase which runs a shell script that executes the Crashlytics | ||
// run command line tool which uploads the debug symbols at build time. | ||
if (platforms.indexOf("ios") !== -1) { | ||
var xcodeProjectPath = utilities.getXcodeProjectPath(context); | ||
iosHelper.removeShellScriptBuildPhase(context, xcodeProjectPath); | ||
iosHelper.addShellScriptBuildPhase(context, xcodeProjectPath); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
/** | ||
|
@@ -10,15 +11,15 @@ var fs = require('fs'); | |
var path = require('path'); | ||
|
||
fs.ensureDirSync = function (dir) { | ||
if (!fs.existsSync(dir)) { | ||
dir.split(path.sep).reduce(function (currentPath, folder) { | ||
currentPath += folder + path.sep; | ||
if (!fs.existsSync(currentPath)) { | ||
fs.mkdirSync(currentPath); | ||
} | ||
return currentPath; | ||
}, ''); | ||
} | ||
if (!fs.existsSync(dir)) { | ||
dir.split(path.sep).reduce(function (currentPath, folder) { | ||
currentPath += folder + path.sep; | ||
if (!fs.existsSync(currentPath)) { | ||
fs.mkdirSync(currentPath); | ||
} | ||
return currentPath; | ||
}, ''); | ||
} | ||
}; | ||
|
||
var config = fs.readFileSync('config.xml').toString(); | ||
|
@@ -28,114 +29,93 @@ var IOS_DIR = 'platforms/ios'; | |
var ANDROID_DIR = 'platforms/android'; | ||
|
||
var PLATFORM = { | ||
IOS: { | ||
dest: [ | ||
IOS_DIR + '/' + name + '/Resources/GoogleService-Info.plist', | ||
IOS_DIR + '/' + name + '/Resources/Resources/GoogleService-Info.plist' | ||
], | ||
src: [ | ||
'GoogleService-Info.plist', | ||
IOS_DIR + '/www/GoogleService-Info.plist', | ||
'www/GoogleService-Info.plist' | ||
] | ||
}, | ||
ANDROID: { | ||
dest: [ | ||
ANDROID_DIR + '/google-services.json' | ||
], | ||
src: [ | ||
'google-services.json', | ||
ANDROID_DIR + '/assets/www/google-services.json', | ||
'www/google-services.json' | ||
], | ||
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' | ||
} | ||
IOS: { | ||
dest: [ | ||
IOS_DIR + '/' + name + '/Resources/GoogleService-Info.plist', | ||
IOS_DIR + '/' + name + '/Resources/Resources/GoogleService-Info.plist' | ||
], | ||
src: [ | ||
'GoogleService-Info.plist', | ||
IOS_DIR + '/www/GoogleService-Info.plist', | ||
'www/GoogleService-Info.plist' | ||
] | ||
}, | ||
ANDROID: { | ||
dest: [ | ||
ANDROID_DIR + '/google-services.json', | ||
ANDROID_DIR + '/app/google-services.json' | ||
], | ||
src: [ | ||
'google-services.json', | ||
ANDROID_DIR + '/assets/www/google-services.json', | ||
'www/google-services.json' | ||
], | ||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this out of scope of the PR? |
||
var json = JSON.parse(contents); | ||
var strings = fs.readFileSync(PLATFORM.ANDROID.stringsXml).toString(); | ||
|
||
// strip non-default value | ||
strings = strings.replace(new RegExp('<string name="google_app_id">([^\@<]+?)</string>', 'i'), ''); | ||
|
||
// strip non-default value | ||
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'); | ||
|
||
// replace the default 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 default 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>'); | ||
|
||
fs.writeFileSync(PLATFORM.ANDROID.stringsXml, strings); | ||
} | ||
|
||
function copyKey(platform, callback) { | ||
for (var i = 0; i < platform.src.length; i++) { | ||
var file = platform.src[i]; | ||
if (fileExists(file)) { | ||
try { | ||
var contents = fs.readFileSync(file).toString(); | ||
|
||
try { | ||
platform.dest.forEach(function (destinationPath) { | ||
var folder = destinationPath.substring(0, destinationPath.lastIndexOf('/')); | ||
fs.ensureDirSync(folder); | ||
fs.writeFileSync(destinationPath, contents); | ||
}); | ||
} catch (e) { | ||
// skip | ||
} | ||
function copyKey (platform, callback) { | ||
for (var i = 0; i < platform.src.length; i++) { | ||
var file = platform.src[i]; | ||
if (fileExists(file)) { | ||
try { | ||
var contents = fs.readFileSync(file).toString(); | ||
|
||
try { | ||
platform.dest.forEach(function (destinationPath) { | ||
var folder = destinationPath.substring(0, destinationPath.lastIndexOf('/')); | ||
fs.ensureDirSync(folder); | ||
fs.writeFileSync(destinationPath, contents); | ||
}); | ||
} catch (e) { | ||
// skip | ||
} | ||
|
||
callback && callback(contents); | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
callback && callback(contents); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
|
||
break; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
|
||
function getValue(config, name) { | ||
var value = config.match(new RegExp('<' + name + '>(.*?)</' + name + '>', 'i')); | ||
if (value && value[1]) { | ||
return value[1] | ||
} else { | ||
return null | ||
} | ||
function getValue (config, name) { | ||
var value = config.match(new RegExp('<' + name + '>(.*?)</' + name + '>', 'i')); | ||
if (value && value[1]) { | ||
return value[1]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
function fileExists(path) { | ||
try { | ||
return fs.statSync(path).isFile(); | ||
} catch (e) { | ||
return false; | ||
} | ||
function fileExists (path) { | ||
try { | ||
return fs.statSync(path).isFile(); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
function directoryExists(path) { | ||
try { | ||
return fs.statSync(path).isDirectory(); | ||
} catch (e) { | ||
return false; | ||
} | ||
function directoryExists (path) { | ||
try { | ||
return fs.statSync(path).isDirectory(); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
module.exports = function(context) { | ||
//get platform from the context supplied by cordova | ||
var platforms = context.opts.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); | ||
} | ||
if (platforms.indexOf('android') !== -1 && directoryExists(ANDROID_DIR)) { | ||
console.log('Preparing Firebase on Android'); | ||
copyKey(PLATFORM.ANDROID, updateStringsXml) | ||
} | ||
}; | ||
module.exports = function (context) { | ||
//get platform from the context supplied by cordova | ||
var platforms = context.opts.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); | ||
} | ||
if (platforms.indexOf('android') !== -1 && directoryExists(ANDROID_DIR)) { | ||
console.log('Preparing Firebase on Android'); | ||
copyKey(PLATFORM.ANDROID); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
var androidHelper = require('./lib/android-helper'); | ||
var iosHelper = require("./lib/ios-helper"); | ||
var utilities = require("./lib/utilities"); | ||
|
||
module.exports = function(context) { | ||
|
||
var platforms = context.opts.cordova.platforms; | ||
|
||
// Remove the Gradle modifications that were added when the plugin was installed. | ||
if (platforms.indexOf("android") !== -1) { | ||
androidHelper.removeFabricBuildToolsFromGradle(); | ||
} | ||
|
||
// Remove the build script that was added when the plugin was installed. | ||
if (platforms.indexOf("ios") !== -1) { | ||
var xcodeProjectPath = utilities.getXcodeProjectPath(context); | ||
iosHelper.removeShellScriptBuildPhase(context, xcodeProjectPath); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var utilities = require("./utilities"); | ||
|
||
module.exports = { | ||
|
||
addFabricBuildToolsGradle: function () { | ||
|
||
var buildGradle = utilities.readBuildGradle(); | ||
|
||
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"); | ||
|
||
buildGradle = buildGradle.replace(/(\/\/ PLUGIN GRADLE EXTENSIONS START)/, addToBuildGradle + '\n\n$1'); | ||
|
||
utilities.writeBuildGradle(buildGradle); | ||
}, | ||
|
||
removeFabricBuildToolsFromGradle: function () { | ||
|
||
var buildGradle = utilities.readBuildGradle(); | ||
|
||
buildGradle = buildGradle.replace(/\n\/\/ Fabric Cordova Plugin - Start Fabric Build Tools[\s\S]*\/\/ Fabric Cordova Plugin - End Fabric Build Tools/, ""); | ||
|
||
utilities.writeBuildGradle(buildGradle); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the removement if those values?