-
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 #2 from chabok-io/dev
v1.1.0
- Loading branch information
Showing
1,945 changed files
with
1,326 additions
and
195,112 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## v1.1.0 | ||
- Update Chabok iOS SDK ([v2.1.0](https://github.com/chabok-io/chabok-client-ios/releases/tag/v2.1.0)) | ||
- Update Chabok android SDK ([v3.1.2](https://github.com/chabok-io/chabok-client-android/releases/tag/v3.1.2)) | ||
- Now SDK install automatically: | ||
``` bash | ||
//SANDBOX | ||
cordova plugin add com.chabokpush.cordova --variable CHABOK_ENVIRONMENT=SANDBOX | ||
|
||
//OR PRODUCTION | ||
cordova plugin add com.chabokpush.cordova --variable CHABOK_ENVIRONMENT=PRODUCTION | ||
``` | ||
- Get notification actions by `setOnNotificationOpenedCallback`. | ||
- Fix get connection status event. |
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,61 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const utilities = require("./utilities"); | ||
|
||
const IOS_DIR = 'platforms/ios'; | ||
const ANDROID_DIR = 'platforms/android'; | ||
|
||
const config = fs.readFileSync('config.xml').toString(); | ||
const name = utilities.getValue(config, 'name'); | ||
|
||
const PLATFORM = { | ||
IOS: { | ||
dest: [ | ||
IOS_DIR + '/' + name + '/Chabok.sandbox.plist', | ||
'plugins/com.chabokpush.cordova/src/ios/Chabok.sandbox.plist', | ||
|
||
IOS_DIR + '/' + name + '/Chabok.production.plist', | ||
'plugins/com.chabokpush.cordova/src/ios/Chabok.production.plist', | ||
], | ||
src: [ | ||
'Chabok.sandbox.plist', | ||
|
||
'Chabok.production.plist', | ||
] | ||
}, | ||
ANDROID: { | ||
dest: [ | ||
ANDROID_DIR + '/app/google-services.json', | ||
|
||
ANDROID_DIR + '/app/Chabok.sandbox.json', | ||
|
||
ANDROID_DIR + '/app/Chabok.production.json' | ||
], | ||
src: [ | ||
'google-services.json', | ||
|
||
'Chabok.sandbox.json', | ||
|
||
'Chabok.production.json', | ||
], | ||
} | ||
}; | ||
|
||
module.exports = function(cordovaContext) { | ||
console.log('(ℹ️) Get Chabok environment variable from config file or user set by adding plugin. \n' + | ||
'(🧪) example: Cordova plugin add com.chabokpush.cordova --variable CHABOK_ENVIRONMENT=PRODUCTION'); | ||
|
||
// Copy key files to their platform specific folders | ||
if (utilities.directoryExists(IOS_DIR)) { | ||
console.log('(📱) Preparing Chabok files on iOS'); | ||
|
||
utilities.copyKey(PLATFORM.IOS, 'iOS'); | ||
} | ||
if (utilities.directoryExists(ANDROID_DIR)) { | ||
console.log('(📱) Preparing Chabok and Firebase files on Android'); | ||
|
||
utilities.copyKey(PLATFORM.ANDROID, '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,120 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const utilities = require("./utilities"); | ||
|
||
const FILE_NAME = 'build.gradle'; | ||
const mavenRepo = 'maven {\n' + | ||
' url "https://plugins.gradle.org/m2/"\n' + | ||
' }'; | ||
|
||
function addChabokLib(context){ | ||
console.log('(LAST) -----> Start to insert Chabok plugin into the ' + FILE_NAME + ' file.'); | ||
|
||
let chabokAndFirebaseGradle = 'classpath "io.chabok.plugin:chabok-services:1.0.0"\n' + | ||
' classpath \'com.google.gms:google-services:4.3.2\''; | ||
|
||
let platformRoot = path.join(context.opts.projectRoot, 'platforms/android'); | ||
|
||
let buildGradleFIle = path.join(platformRoot, FILE_NAME); | ||
|
||
if (fs.existsSync(buildGradleFIle)) { | ||
console.log('The ' + FILE_NAME + ' file is exist and start to read the file.'); | ||
|
||
fs.readFile(buildGradleFIle, 'utf8', function (err, data) { | ||
if (err) { | ||
throw new Error('Unable to find ' + FILE_NAME + ': ' + err); | ||
} | ||
|
||
if (!data.includes(mavenRepo)) { | ||
data = data.replace('jcenter()', | ||
'jcenter()\n ' + mavenRepo); | ||
|
||
console.log('Add maven plugin into the Android '+FILE_NAME+'. \n\n' + data); | ||
|
||
fs.writeFile(buildGradleFIle, data, 'utf8', function (err) { | ||
if (err) { | ||
throw new Error('Unable to write ' + FILE_NAME + ': ' + err); | ||
} else { | ||
console.info('Add maven plugin in '+FILE_NAME+' file successfully.'); | ||
} | ||
}) | ||
} else { | ||
console.warn('maven plugin already added.'); | ||
} | ||
|
||
if (!data.includes(chabokAndFirebaseGradle)) { | ||
let result = data.replace('classpath \'com.android.tools.build:gradle', | ||
chabokAndFirebaseGradle + '\n classpath \'com.android.tools.build:gradle'); | ||
|
||
console.log('Add Chabok plugin into the Android '+FILE_NAME+'. \n\n' + result); | ||
|
||
fs.writeFile(buildGradleFIle, result, 'utf8', function (err) { | ||
if (err) { | ||
throw new Error('Unable to write ' + FILE_NAME + ': ' + err); | ||
} else { | ||
console.info('Add Chabok plugin in '+FILE_NAME+' file successfully.'); | ||
} | ||
}) | ||
} else { | ||
console.warn('Chabok plugin already added.'); | ||
} | ||
}); | ||
} else { | ||
console.warn('Could not find '+FILE_NAME+' file.'); | ||
} | ||
} | ||
|
||
function removeChabokLib(context){ | ||
console.log('-----> Start to remove Chabok plugin into the ' + FILE_NAME + ' file.'); | ||
|
||
let chabokAndFirebaseGradle = 'classpath \'com.google.gms:google-services:4.3.2\'\n' + | ||
' classpath \'com.android.tools.build:gradle:3.5.1\''; | ||
|
||
let platformRoot = path.join(context.opts.projectRoot, 'platforms/android'); | ||
|
||
let buildGradleFIle = path.join(platformRoot, FILE_NAME); | ||
|
||
if (fs.existsSync(buildGradleFIle)) { | ||
console.log('The ' + FILE_NAME + ' file is exist and start to read the file.'); | ||
|
||
fs.readFile(buildGradleFIle, 'utf8', function (err, data) { | ||
if (err) { | ||
throw new Error('Unable to find ' + FILE_NAME + ': ' + err); | ||
} | ||
|
||
if (data.includes(mavenRepo)) { | ||
let result = data.replace('jcenter()' + mavenRepo, | ||
'jcenter()' | ||
); | ||
|
||
result = result.replace( | ||
'classpath "io.chabok.plugin:chabok-services:1.0.0" \n\n' + chabokAndFirebaseGradle, | ||
'classpath \'com.android.tools.build:gradle:3.5.1\''); | ||
|
||
console.log('Removed Chabok plugin from the Android '+FILE_NAME+'. \n\n' + result); | ||
|
||
fs.writeFile(buildGradleFIle, result, 'utf8', function (err) { | ||
if (err) { | ||
throw new Error('Unable to write ' + FILE_NAME + ': ' + err); | ||
} else { | ||
console.info('Removed Chabok plugin in '+FILE_NAME+' file successfully.'); | ||
} | ||
}) | ||
} else { | ||
console.warn('Chabok plugin already removed.'); | ||
} | ||
}); | ||
} else { | ||
console.warn('Could not find '+FILE_NAME+' file.'); | ||
} | ||
} | ||
|
||
module.exports = function(context) { | ||
if (context.hook === 'before_plugin_uninstall'){ | ||
removeChabokLib(context); | ||
} else { | ||
addChabokLib(context); | ||
} | ||
}; |
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,89 @@ | ||
#!/usr/bin/env node | ||
|
||
let fs = require('fs'); | ||
let path = require('path'); | ||
|
||
let APP_CLASS = 'com.chabokpush.cordova.MyAppClass'; | ||
let FILE_NAME = 'AndroidManifest.xml' | ||
|
||
function replaceClassName(currentCode, withClass, context){ | ||
console.log('-----> Start to insert Chabok application class into the' + FILE_NAME + 'file.'); | ||
|
||
let platformRoot = path.join(context.opts.projectRoot, 'platforms/android/app/src/main'); | ||
let manifestFile = path.join(platformRoot, FILE_NAME); | ||
|
||
if (fs.existsSync(manifestFile)) { | ||
console.log('The ' + FILE_NAME + ' file is exist and start to read the file.'); | ||
|
||
fs.readFile(manifestFile, 'utf8', function (err, data) { | ||
if (err) { | ||
throw new Error('Unable to find ' + FILE_NAME + ': ' + err); | ||
} | ||
|
||
if (data.indexOf(APP_CLASS) === -1) { | ||
if (!data.includes(APP_CLASS)) { | ||
let result = data.replace(currentCode, withClass); | ||
|
||
fs.writeFile(manifestFile, result, 'utf8', function (err) { | ||
if (err) { | ||
throw new Error('Unable to write ' + FILE_NAME + ': ' + err); | ||
} else { | ||
console.info('Add Chabok application class name into the AndroidManifest.xml file successfully.'); | ||
} | ||
}) | ||
} else { | ||
console.warn( 'Chabok application class name already added to ' + FILE_NAME); | ||
} | ||
} else { | ||
console.warn( 'data contain (' + APP_CLASS + ') file and ignore to add class name to manifest.'); | ||
} | ||
}); | ||
} else { | ||
console.warn('Could not find AndroidManifest.xml file.'); | ||
} | ||
} | ||
|
||
function insertChabokApplicationClass(context){ | ||
replaceClassName(/<application/g, '<application android:name="' + APP_CLASS + '"', context) | ||
} | ||
|
||
function removeChabokApplicationClass(context){ | ||
console.log('-----> Start to remove Chabok application class into the' + FILE_NAME + ' file.'); | ||
|
||
let platformRoot = path.join(context.opts.projectRoot, 'platforms/android/app/src/main'); | ||
let manifestFile = path.join(platformRoot, FILE_NAME); | ||
|
||
if (fs.existsSync(manifestFile)) { | ||
console.log('The ' + FILE_NAME + ' file is exist and start to read the file.'); | ||
|
||
fs.readFile(manifestFile, 'utf8', function (err, data) { | ||
if (err) { | ||
throw new Error('Unable to find ' + FILE_NAME + ': ' + err); | ||
} | ||
|
||
if (data.indexOf(APP_CLASS)) { | ||
let result = data.replace('android:name="' + APP_CLASS + '"', ''); | ||
|
||
fs.writeFile(manifestFile, result, 'utf8', function (err) { | ||
if (err) { | ||
throw new Error('Unable to write ' + FILE_NAME + ': ' + err); | ||
} else { | ||
console.info('Removed Chabok application class name into the AndroidManifest.xml file successfully.'); | ||
} | ||
}) | ||
} else { | ||
console.warn( 'data contain (' + APP_CLASS + ') file and ignore to remove class name to manifest.'); | ||
} | ||
}); | ||
} else { | ||
console.warn('Could not find AndroidManifest.xml file.'); | ||
} | ||
} | ||
|
||
module.exports = function(context) { | ||
if (context.hook === 'before_plugin_uninstall'){ | ||
removeChabokApplicationClass(context); | ||
} else { | ||
insertChabokApplicationClass(context); | ||
} | ||
}; |
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,56 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const utilities = require("./utilities"); | ||
|
||
let ChabokImport = 'import com.adpdigital.push.AdpPushClient;\n' + | ||
'import com.adpdigital.push.config.Environment;'; | ||
|
||
let FILE_NAME = 'MyAppClass.java' | ||
|
||
module.exports = function(context) { | ||
let chkEnv = utilities.readChabokEnvFromProcess(context.cmdLine); | ||
let ChabokConfigEnv = 'AdpPushClient.configureEnvironment(Environment.'+chkEnv.toUpperCase()+');'; | ||
|
||
console.log('-----> Start to insert Chabok application class into the ' + FILE_NAME + 'file.'); | ||
|
||
let platformRoot = path.join(context.opts.projectRoot, 'platforms/android/app/src/main/java/com/chabokpush/cordova'); | ||
|
||
let applicationClass = path.join(platformRoot, FILE_NAME); | ||
|
||
if (fs.existsSync(applicationClass)) { | ||
console.log('The ' + FILE_NAME + ' file is exist and start to read the file.'); | ||
|
||
fs.readFile(applicationClass, 'utf8', function (err, data) { | ||
if (err) { | ||
throw new Error('Unable to find ' + FILE_NAME + ': ' + err); | ||
} | ||
|
||
if (data.indexOf(FILE_NAME) === -1) { | ||
if (!data.includes(ChabokImport)) { | ||
let result = data.replace('import android.app.Application;', 'import android.app.Application; \n' + ChabokImport); | ||
|
||
result = result.replace('super.onCreate();', 'super.onCreate();' + | ||
' \n \n ' + ChabokConfigEnv); | ||
|
||
console.log('Add Chabok configureEnvironment method into the Android Application class. \n\n' + result); | ||
|
||
fs.writeFile(applicationClass, result, 'utf8', function (err) { | ||
if (err) { | ||
throw new Error('Unable to write ' + FILE_NAME + ': ' + err); | ||
} else { | ||
console.info('Add Chabok class import in application class successfully.'); | ||
} | ||
}) | ||
} else { | ||
console.warn( 'Chabok import into application class already added.'); | ||
} | ||
} else { | ||
console.warn( 'data contain ' + FILE_NAME + ' file and ignore to add ' + FILE_NAME + ' name.'); | ||
} | ||
}); | ||
} else { | ||
console.warn('Could not find '+FILE_NAME+' file.'); | ||
} | ||
}; |
Oops, something went wrong.