forked from arnesson/cordova-plugin-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request arnesson#325 from jestcastro/master
IOS-ANDROID PHONE AUTH
- Loading branch information
Showing
71 changed files
with
3,141 additions
and
319 deletions.
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
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
"cordova-browser", | ||
"firebase", | ||
"push", | ||
"notifications" | ||
"notifications", | ||
"phone auth" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,141 +1,141 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
/** | ||
* This hook makes sure projects using [cordova-plugin-firebase](https://github.com/arnesson/cordova-plugin-firebase) | ||
* will build properly and have the required key files copied to the proper destinations when the app is build on Ionic Cloud using the package command. | ||
* Credits: https://github.com/arnesson. | ||
*/ | ||
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; | ||
}, ''); | ||
} | ||
}; | ||
|
||
var config = fs.readFileSync('config.xml').toString(); | ||
var name = getValue(config, 'name'); | ||
|
||
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: ANDROID_DIR + '/res/values/strings.xml' | ||
} | ||
}; | ||
|
||
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('<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 | ||
} | ||
|
||
callback && callback(contents); | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
|
||
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 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; | ||
} | ||
} | ||
|
||
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) | ||
} | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
/** | ||
* This hook makes sure projects using [cordova-plugin-firebase](https://github.com/arnesson/cordova-plugin-firebase) | ||
* will build properly and have the required key files copied to the proper destinations when the app is build on Ionic Cloud using the package command. | ||
* Credits: https://github.com/arnesson. | ||
*/ | ||
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; | ||
}, ''); | ||
} | ||
}; | ||
|
||
var config = fs.readFileSync('config.xml').toString(); | ||
var name = getValue(config, 'name'); | ||
|
||
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: ANDROID_DIR + '/res/values/strings.xml' | ||
} | ||
}; | ||
|
||
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('<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 | ||
} | ||
|
||
callback && callback(contents); | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
|
||
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 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; | ||
} | ||
} | ||
|
||
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) | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -693,4 +693,4 @@ public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingTo | |
} | ||
}); | ||
} | ||
} | ||
} |
Binary file modified
BIN
+370 KB
(100%)
src/ios/Firebase/Analytics/FirebaseAnalytics.framework/FirebaseAnalytics
Binary file not shown.
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
Oops, something went wrong.