cordova-plugin-appice 2.0.9 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +0 -2
  2. package/example/config.xml +59 -59
  3. package/example/package.json +38 -38
  4. package/example/res/ai_android.pem +40 -40
  5. package/example/www/css/index.css +116 -116
  6. package/example/www/index.html +62 -62
  7. package/example/www/js/index.js +111 -102
  8. package/package.json +20 -2
  9. package/plugin.xml +193 -128
  10. package/scripts/BeforeAndroidBuilt.js +165 -102
  11. package/scripts/BeforeIosBuilt.js +35 -35
  12. package/scripts/androidAfterPluginAdd.js +67 -67
  13. package/scripts/androidAfterPluginRm.js +112 -112
  14. package/scripts/iOSAfterPluginAdd.js +58 -58
  15. package/scripts/iOSAfterPluginRm.js +30 -31
  16. package/src/android/AppICEFCMPush.java +26 -0
  17. package/src/android/AppICEMFPPush.java +67 -0
  18. package/{libcordova/src/main/java/com/appice/cordova → src/android}/AppICEPlugin.java +984 -968
  19. package/src/android/AppICEPushHandler.java +163 -0
  20. package/{libcordova/src/main/java/com/appice/cordova → src/android}/CampaignCampsReceiver.java +94 -95
  21. package/{libcordova/src/main/java/com/appice/cordova → src/android}/NotificationEventService.java +64 -55
  22. package/src/build.gradle +4 -2
  23. package/src/ios/AppDelegate+AppICEPlugin.m +178 -89
  24. package/src/ios/AppICEPlugin.h +3 -0
  25. package/src/ios/AppICEPlugin.m +55 -10
  26. package/www/AppICE.js +261 -228
  27. package/libcordova/android-release-aar.gradle +0 -63
  28. package/libcordova/build.gradle +0 -50
  29. package/libcordova/cordova.jar +0 -0
  30. package/libcordova/proguard-rules.pro +0 -21
  31. package/libcordova/src/main/AndroidManifest.xml +0 -24
  32. package/libcordova/src/main/res/values/strings.xml +0 -3
  33. package/src/firebase/modified/modified.iml +0 -11
  34. package/src/firebase/original/original.iml +0 -11
@@ -1,126 +1,189 @@
1
- module.exports = function(context) {
2
- var fs =require ('fs');
1
+ module.exports = function (context) {
2
+ var fs = require('fs');
3
3
  var path = require('path');
4
4
  var shell = require('shelljs');
5
-
5
+
6
6
  var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
7
7
  var platformRootios = path.join(context.opts.projectRoot, 'platforms/ios');
8
-
8
+
9
9
  var root_cert = path.join(context.opts.projectRoot, 'res');
10
10
  //var root_cert_ios = path.join(context.opts.projectRoot, 'res/ai_ios.cer');
11
11
 
12
- const cordovaCommon = context.requireCordovaModule('cordova-common');
13
- const appConfig = new cordovaCommon.ConfigParser('config.xml');
14
- const appName = appConfig.name();
15
- var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "android");
16
- var APPICE_APPLICATIONCLASS_INCLUDE= appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "android");
17
- var MFP_PUSH=appConfig.getPlatformPreference("MFP_PUSH", "android");
18
- var SSL_PINNING=appConfig.getPlatformPreference("SSL_PINNING", "android");
12
+ const cordovaCommon = context.requireCordovaModule('cordova-common');
13
+ const appConfig = new cordovaCommon.ConfigParser('config.xml');
14
+ const appName = appConfig.name();
15
+ var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "android");
16
+ var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "android");
17
+ var MFP_PUSH = appConfig.getPlatformPreference("MFP_PUSH", "android");
18
+ var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "android");
19
19
 
20
20
 
21
- var project_properties=path.join(platformRoot,'project.properties');
22
- ///for SSL pinning
21
+ var project_properties = path.join(platformRoot, 'project.properties');
22
+ ///for SSL pinning
23
23
 
24
+ var appBuildGradlePath = path.join(platformRoot, 'app/build.gradle'); // Path to the app's build.gradle file
25
+ const pluginName = 'cordova-plugin-appice';
26
+ const pluginXmlPath = path.join(context.opts.projectRoot, 'plugins', pluginName, 'plugin.xml');
27
+ const sourceFileEntry = '<source-file src="src/android/AppICEMFPPush.java" target-dir="com/appice/cordova/" />';
28
+ const sourceFileEntryFCM = '<source-file src="src/android/AppICEFCMPush.java" target-dir="com/appice/cordova/" />';
24
29
 
25
- if (MFP_PUSH === "true"){
26
- var manifestFileNew = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
27
-
28
- if (fs.existsSync(manifestFileNew)) {
29
- try {
30
- fs.readFile(manifestFileNew, 'utf8', function (err,data) {
31
- if (err) {
32
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
33
- }
34
- var serviceTag='<service android:exported="true" android:name="com.appice.appicemfppush.AppICEMFPPush">';
35
- if (data.indexOf(serviceTag) == -1) {
36
- var result = data.replace(/<service android:exported="false" android:name="com.ibm.fcmtest.myIntentService">/g,serviceTag);
37
- fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
38
- if (err) {
39
- var result = data.replace(/<service android:exported="false" android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNewIntentService">/g,serviceTag);
40
- fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
41
- if (err) {
42
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
43
- }
44
-
45
- });
46
- }
47
-
48
- });
49
-
50
- }
51
- });
52
- } catch(err) {
53
- }
54
- } else{
55
- var manifestFileNewRoot = path.join(platformRoot, 'AndroidManifest.xml');
56
- if (fs.existsSync(manifestFileNewRoot)) {
57
- try {
58
- fs.readFile(manifestFileNewRoot, 'utf8', function (err,data) {
59
- if (err) {
60
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
61
- }
62
- var serviceTag='<service android:exported="true" android:name="com.appice.appicemfppush.AppICEMFPPush">';
63
-
64
- if (data.indexOf(serviceTag) == -1) {
65
- var result = data.replace(/<service android:exported="false" android:name="com.ibm.fcmtest.myIntentService">/g,serviceTag);
66
- fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
67
- if (err) {
68
-
69
- var result = data.replace(/<service android:exported="false" android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNewIntentService">/g,serviceTag);
70
- fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
71
- if (err) {
72
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
73
- }
74
-
75
- });
76
- }
77
-
78
- });
79
-
80
- }
81
- });
82
- } catch(err) {
83
- }
30
+ if (MFP_PUSH === "true") {
31
+ var manifestFileNew = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
32
+
33
+ if (fs.existsSync(manifestFileNew)) {
34
+ try {
35
+ fs.readFile(manifestFileNew, 'utf8', function (err, data) {
36
+ if (err) {
37
+ throw new Error('Unable to find AndroidManifest.xml: ' + err);
84
38
  }
85
- }
86
-
87
- if(fs.existsSync(project_properties)){
88
- try {
89
- fs.readFile(project_properties, 'utf8', function (err,data) {
39
+ var serviceTag = '<service android:exported="true" android:name="com.appice.cordova.AppICEMFPPush">';
40
+
41
+ if (data.indexOf(serviceTag) == -1) {
42
+ var result = data.replace(/<service android:exported="false" android:name="com.ibm.fcmtest.myIntentService">/g, serviceTag);
43
+ fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
90
44
  if (err) {
91
- throw new Error('Unable to find project_properties: ' + err);
45
+ throw new Error('Unable to write into AndroidManifest.xml: ' + err);
92
46
  }
93
- var modifiedBuildGradle = data ;
94
47
  });
95
48
  }
96
- catch(err) {
97
- console.log("project_properties found :",err);
98
- }
99
- }
100
- }
101
-
102
- if(SSL_PINNING === "true"){
103
-
104
- var target_cert_android = path.join(platformRoot, '/app/src/main/assets/');
105
- var target_cert_ios = path.join(platformRootios, appName+'/Resources/');
106
- //checking existing in android
107
- if (fs.existsSync(target_cert_android+'ai_android.pem')) {
108
- try {
109
- shell.rm('-Rf', target_cert_android+'ai_android.pem');
110
- } catch(err) {
49
+ });
50
+ } catch (err) {
51
+ }
52
+
53
+ // Add the dependency to the app's build.gradle file
54
+ try {
55
+ const buildGradleContent = fs.readFileSync(appBuildGradlePath, 'utf8');
56
+
57
+ // Dependencies to be added
58
+ const dependencies = [
59
+ "com.ibm.mobilefirstplatform.clientsdk.android:core:3.+",
60
+ "com.ibm.mobilefirstplatform.clientsdk.android:push:4.3.2"
61
+ ];
62
+
63
+ for (const dependency of dependencies) {
64
+ if (!buildGradleContent.includes(dependency)) {
65
+ const dependencyLine = `implementation '${dependency}'`;
66
+ fs.appendFileSync(appBuildGradlePath, '\n' + dependencyLine);
67
+ console.log(`Added dependency '${dependency}' to ${appBuildGradlePath}`);
68
+ } else {
69
+ console.log(`Dependency '${dependency}' already exists in ${appBuildGradlePath}`);
111
70
  }
112
71
  }
72
+ } catch (err) {
73
+ console.error(`Failed to modify ${appBuildGradlePath}: ${err}`);
74
+ }
75
+
76
+ try {
77
+ const pluginXmlContent = fs.readFileSync(pluginXmlPath, 'utf8');
113
78
 
79
+ if (pluginXmlContent.indexOf(sourceFileEntry) === -1) {
80
+ const platformPosition = pluginXmlContent.indexOf('<platform name="android">');
81
+ const updatedPluginXmlContent = pluginXmlContent.slice(0, platformPosition) + '\n' + sourceFileEntry + '\n' + pluginXmlContent.slice(platformPosition);
114
82
 
115
- //putting files in assest folder for android
116
- var android_Certificate = path.join(root_cert, 'ai_android.pem');
83
+ fs.writeFileSync(pluginXmlPath, updatedPluginXmlContent, 'utf8');
84
+ console.log(`Added <source-file> entry to ${pluginXmlPath}`);
85
+ } else {
86
+ console.log(`<source-file> entry already exists in ${pluginXmlPath}`);
87
+ }
88
+ } catch (err) {
89
+ console.error(`Failed to modify ${pluginXmlPath}: ${err}`);
90
+ }
91
+ } else {
92
+ var manifestFileNewRoot = path.join(platformRoot, 'AndroidManifest.xml');
93
+ if (fs.existsSync(manifestFileNewRoot)) {
117
94
  try {
118
- shell.cp('-f', android_Certificate, target_cert_android);
119
- console.log("android_Certificate copied");
120
- } catch(err) {
121
- console.log("android_Certificate Failed");
95
+ fs.readFile(manifestFileNewRoot, 'utf8', function (err, data) {
96
+ if (err) {
97
+ throw new Error('Unable to find AndroidManifest.xml: ' + err);
98
+ }
99
+ var serviceTag = '<service android:exported="true" android:name="com.appice.cordova.AppICEMFPPush">';
100
+
101
+ if (data.indexOf(serviceTag) == -1) {
102
+ var result = data.replace(/<service android:exported="false" android:name="com.ibm.fcmtest.myIntentService">/g, serviceTag);
103
+ fs.writeFile(manifestFileNewRoot, result, 'utf8', function (err) {
104
+ if (err) {
105
+ throw new Error('Unable to write into AndroidManifest.xml: ' + err);
106
+ }
107
+ });
108
+ }
109
+ });
110
+ } catch (err) {
122
111
  }
112
+ }
113
+ }
114
+ } else {
115
+
116
+ const manifestPath = '/app/src/main/AndroidManifest.xml';
123
117
 
124
-
118
+ // Read existing manifest file
119
+ fs.readFile(manifestPath, 'utf-8', (err, data) => {
120
+ if (err) {
121
+ console.error('Error reading manifest file:', err);
122
+ return;
125
123
  }
126
- }
124
+
125
+ // Find the position to insert the service tag
126
+ const serviceIntentFilter = ' <intent-filter>\n <action android:name="com.google.firebase.MESSAGING_EVENT" />\n </intent-filter>\n';
127
+ const serviceTag = ` <service android:name="com.appice.cordova.AppICEFCMPush">\n${serviceIntentFilter} </service>\n`;
128
+
129
+ const index = data.indexOf('</application>');
130
+ if (index === -1) {
131
+ console.error('Error: Could not find </application> tag in AndroidManifest.xml');
132
+ return;
133
+ }
134
+
135
+ // Insert the service tag just before the </application> tag
136
+ const updatedManifest = data.slice(0, index) + serviceTag + data.slice(index);
137
+
138
+ // Write the updated manifest back to file
139
+ fs.writeFile(manifestPath, updatedManifest, 'utf-8', (err) => {
140
+ if (err) {
141
+ console.error('Error writing manifest file:', err);
142
+ return;
143
+ }
144
+ console.log('Firebase Cloud Messaging service tag added to AndroidManifest.xml successfully!');
145
+ });
146
+ });
147
+ try {
148
+ const pluginXmlContent = fs.readFileSync(pluginXmlPath, 'utf8');
149
+
150
+ if (pluginXmlContent.indexOf(sourceFileEntry) === -1) {
151
+ const platformPosition = pluginXmlContent.indexOf('<platform name="android">');
152
+ const updatedPluginXmlContent = pluginXmlContent.slice(0, platformPosition) + '\n' + sourceFileEntryFCM + '\n' + pluginXmlContent.slice(platformPosition);
153
+
154
+ fs.writeFileSync(pluginXmlPath, updatedPluginXmlContent, 'utf8');
155
+ console.log(`Added <source-file> entry to ${pluginXmlPath}`);
156
+ } else {
157
+ console.log(`<source-file> entry already exists in ${pluginXmlPath}`);
158
+ }
159
+ } catch (err) {
160
+ console.error(`Failed to modify ${pluginXmlPath}: ${err}`);
161
+ }
162
+
163
+ }
164
+
165
+ if (SSL_PINNING === "true") {
166
+
167
+ var target_cert_android = path.join(platformRoot, '/app/src/main/assets/');
168
+ var target_cert_ios = path.join(platformRootios, appName + '/Resources/');
169
+ //checking existing in android
170
+ if (fs.existsSync(target_cert_android + 'ai_android.pem')) {
171
+ try {
172
+ shell.rm('-Rf', target_cert_android + 'ai_android.pem');
173
+ } catch (err) {
174
+ }
175
+ }
176
+
177
+
178
+ //putting files in assest folder for android
179
+ var android_Certificate = path.join(root_cert, 'ai_android.pem');
180
+ try {
181
+ shell.cp('-f', android_Certificate, target_cert_android);
182
+ console.log("android_Certificate copied");
183
+ } catch (err) {
184
+ console.log("android_Certificate Failed");
185
+ }
186
+
187
+
188
+ }
189
+ }
@@ -1,39 +1,39 @@
1
- module.exports = function(context) {
2
-
3
- var fs =require ('fs');
4
- var path = require('path');
5
- var shell = require('shelljs');
6
-
7
- var platformRootios = path.join(context.opts.projectRoot, 'platforms/ios');
8
-
9
- var root_cert = path.join(context.opts.projectRoot, 'res');
10
- //var root_cert_ios = path.join(context.opts.projectRoot, 'res/ai_ios.cer');
11
-
12
- const cordovaCommon = context.requireCordovaModule('cordova-common');
13
- const appConfig = new cordovaCommon.ConfigParser('config.xml');
14
- const appName = appConfig.name();
15
-
16
- var SSL_PINNING=appConfig.getPlatformPreference("SSL_PINNING", "android");
17
- if(SSL_PINNING === "true"){
18
-
19
- var target_cert_ios = path.join(platformRootios, appName+'/Resources/');
20
-
21
-
22
- //checking in ios
23
- if (fs.existsSync(target_cert_ios+'ai_ios.der')) {
24
- try {
25
- shell.rm('-Rf', target_cert_ios+'ai_ios.der');
26
- } catch(err) {
1
+ module.exports = function (context) {
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var shell = require('shelljs');
6
+
7
+ var platformRootios = path.join(context.opts.projectRoot, 'platforms/ios');
8
+
9
+ var root_cert = path.join(context.opts.projectRoot, 'res');
10
+ //var root_cert_ios = path.join(context.opts.projectRoot, 'res/ai_ios.cer');
11
+
12
+ const cordovaCommon = context.requireCordovaModule('cordova-common');
13
+ const appConfig = new cordovaCommon.ConfigParser('config.xml');
14
+ const appName = appConfig.name();
15
+
16
+ var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "android");
17
+ if (SSL_PINNING === "true") {
18
+
19
+ var target_cert_ios = path.join(platformRootios, appName + '/Resources/');
20
+
21
+
22
+ //checking in ios
23
+ if (fs.existsSync(target_cert_ios + 'ai_ios.der')) {
24
+ try {
25
+ shell.rm('-Rf', target_cert_ios + 'ai_ios.der');
26
+ } catch (err) {
27
+ }
27
28
  }
28
- }
29
29
 
30
- ////putting files in assest folder for ios
31
- var ios_Certificate=path.join(root_cert, 'ai_ios.der');
32
- try {
33
- shell.cp('-f', ios_Certificate, target_cert_ios);
34
- console.log("ios_Certificate copied");
35
- } catch(err) {
36
- console.log("ios_Certificate Failed");
30
+ ////putting files in assest folder for ios
31
+ var ios_Certificate = path.join(root_cert, 'ai_ios.der');
32
+ try {
33
+ shell.cp('-f', ios_Certificate, target_cert_ios);
34
+ console.log("ios_Certificate copied");
35
+ } catch (err) {
36
+ console.log("ios_Certificate Failed");
37
+ }
37
38
  }
38
- }
39
39
  }
@@ -1,69 +1,69 @@
1
- module.exports = function(context) {
2
- var fs =require ('fs');
1
+ module.exports = function (context) {
2
+ var fs = require('fs');
3
3
  var path = require('path');
4
- var shell = require('shelljs');
5
-
4
+ var shell = require('shelljs');
5
+
6
6
  var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
7
7
  var pluginsFirebaseRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-firebasex');
8
8
  var pluginsAppiceRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-appice');
9
9
 
10
- const cordovaCommon = context.requireCordovaModule('cordova-common');
11
- const appConfig = new cordovaCommon.ConfigParser('config.xml');
10
+ const cordovaCommon = context.requireCordovaModule('cordova-common');
11
+ const appConfig = new cordovaCommon.ConfigParser('config.xml');
12
12
 
13
- var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "android");
14
- var APPICE_APPLICATIONCLASS_INCLUDE= appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "android");
15
- var MFP_PUSH=appConfig.getPlatformPreference("MFP_PUSH", "android");
16
- var SSL_PINNING=appConfig.getPlatformPreference("SSL_PINNING", "android");
17
- var project_properties=path.join(platformRoot,'project.properties');
13
+ var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "android");
14
+ var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "android");
15
+ var MFP_PUSH = appConfig.getPlatformPreference("MFP_PUSH", "android");
16
+ var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "android");
17
+ var project_properties = path.join(platformRoot, 'project.properties');
18
18
 
19
- console.log("platformPreference : "+APPICE_FIREBASE_UPDATE);
20
- if(APPICE_FIREBASE_UPDATE === "true"){
21
- console.log("else true APPICE_FIREBASE_UPDATE : "+APPICE_FIREBASE_UPDATE);
19
+ console.log("platformPreference : " + APPICE_FIREBASE_UPDATE);
20
+ if (APPICE_FIREBASE_UPDATE === "true") {
21
+ console.log("else true APPICE_FIREBASE_UPDATE : " + APPICE_FIREBASE_UPDATE);
22
22
  var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
23
23
  if (fs.existsSync(firebaseFile1)) {
24
24
  try {
25
25
  shell.rm('-Rf', firebaseFile1);
26
- } catch(err) {
26
+ } catch (err) {
27
27
  }
28
28
  }
29
-
29
+
30
30
  var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/android/FirebasePluginMessagingService.java');
31
31
  try {
32
32
  shell.cp('-f', modifiedFile1, firebaseFile1);
33
- } catch(err) {
33
+ } catch (err) {
34
34
  }
35
35
  var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
36
36
  if (fs.existsSync(firebaseFile2)) {
37
37
  try {
38
38
  shell.rm('-Rf', firebaseFile2);
39
- } catch(err) {
39
+ } catch (err) {
40
40
  }
41
41
  }
42
42
  try {
43
43
  shell.cp('-f', modifiedFile1, firebaseFile2);
44
- } catch(err) {
44
+ } catch (err) {
45
45
  }
46
46
  }
47
- //////
48
- var platformwww1 = path.join(platformRoot, '/platform_www/plugins/cordova-plugin-appice/www/AppICE.js');
49
- var platformwww2 = path.join(pluginsAppiceRoot, '/www/AppICE.js');
50
- if (fs.existsSync(platformwww1)) {
51
- try {
52
- shell.rm('-Rf', platformwww1);
53
- } catch(err) {
54
- }
55
- }
47
+ //////
48
+ var platformwww1 = path.join(platformRoot, '/platform_www/plugins/cordova-plugin-appice/www/AppICE.js');
49
+ var platformwww2 = path.join(pluginsAppiceRoot, '/www/AppICE.js');
50
+ if (fs.existsSync(platformwww1)) {
56
51
  try {
57
- shell.cp('-f', platformwww2, platformwww1);
58
- } catch(err) {
52
+ shell.rm('-Rf', platformwww1);
53
+ } catch (err) {
59
54
  }
55
+ }
56
+ try {
57
+ shell.cp('-f', platformwww2, platformwww1);
58
+ } catch (err) {
59
+ }
60
60
  ////
61
61
 
62
- if(APPICE_APPLICATIONCLASS_INCLUDE === "true"){
62
+ if (APPICE_APPLICATIONCLASS_INCLUDE === "true") {
63
63
  var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
64
64
  if (fs.existsSync(manifestFile)) {
65
65
  try {
66
- fs.readFile(manifestFile, 'utf8', function (err,data) {
66
+ fs.readFile(manifestFile, 'utf8', function (err, data) {
67
67
  if (err) {
68
68
  throw new Error('Unable to find AndroidManifest.xml: ' + err);
69
69
  }
@@ -77,14 +77,14 @@ const appConfig = new cordovaCommon.ConfigParser('config.xml');
77
77
  });
78
78
  }
79
79
  });
80
- } catch(err) {
80
+ } catch (err) {
81
81
  }
82
82
  }
83
83
  else {
84
84
  var manifestFileNew = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
85
85
  if (fs.existsSync(manifestFileNew)) {
86
86
  try {
87
- fs.readFile(manifestFileNew, 'utf8', function (err,data) {
87
+ fs.readFile(manifestFileNew, 'utf8', function (err, data) {
88
88
  if (err) {
89
89
  throw new Error('Unable to find AndroidManifest.xml: ' + err);
90
90
  }
@@ -98,62 +98,62 @@ const appConfig = new cordovaCommon.ConfigParser('config.xml');
98
98
  });
99
99
  }
100
100
  });
101
- } catch(err) {
101
+ } catch (err) {
102
102
  }
103
103
  }
104
104
  }
105
105
  }
106
106
 
107
-
108
- if(SSL_PINNING === "true"){
109
- var manifestFileNew_ = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
110
- if(fs.existsSync(manifestFileNew_)){
111
- try{
112
- fs.readFile(manifestFileNew_, 'utf8', function (err,data_) {
113
- if (err) {
114
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
115
- }
116
-
107
+
108
+ if (SSL_PINNING === "true") {
109
+ var manifestFileNew_ = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
110
+ if (fs.existsSync(manifestFileNew_)) {
111
+ try {
112
+ fs.readFile(manifestFileNew_, 'utf8', function (err, data_) {
113
+ if (err) {
114
+ throw new Error('Unable to find AndroidManifest.xml: ' + err);
115
+ }
116
+
117
117
  var SSL_PINNING_meta = '\n<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
118
118
  if (data_.indexOf(SSL_PINNING_meta) == -1) {
119
- var result_ = data_.replace('</application>',SSL_PINNING_meta+'\n</application>');
119
+ var result_ = data_.replace('</application>', SSL_PINNING_meta + '\n</application>');
120
120
  fs.writeFile(manifestFileNew_, result_, 'utf8', function (err) {
121
121
  if (err) {
122
122
  throw new Error('Unable to write into AndroidManifest.xml: ' + err);
123
123
  }
124
124
  });
125
-
125
+
126
126
  }
127
- });
128
- }
129
- catch(err) {
127
+ });
130
128
  }
131
- }else{
132
- var manifestFileNewRoot_ = path.join(platformRoot, 'AndroidManifest.xml');
133
- if(fs.existsSync(manifestFileNewRoot_)){
134
- try{
135
- fs.readFile(manifestFileNewRoot_, 'utf8', function (err,data_) {
136
- if (err) {
137
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
138
- }
139
- ///for SSL pinning
129
+ catch (err) {
130
+ }
131
+ } else {
132
+ var manifestFileNewRoot_ = path.join(platformRoot, 'AndroidManifest.xml');
133
+ if (fs.existsSync(manifestFileNewRoot_)) {
134
+ try {
135
+ fs.readFile(manifestFileNewRoot_, 'utf8', function (err, data_) {
136
+ if (err) {
137
+ throw new Error('Unable to find AndroidManifest.xml: ' + err);
138
+ }
139
+ ///for SSL pinning
140
140
  var SSL_PINNING_meta = '<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
141
141
  if (data_.indexOf(SSL_PINNING_meta) == -1) {
142
- var result_ = data_.replace('</application>',SSL_PINNING_meta+'</application>');
142
+ var result_ = data_.replace('</application>', SSL_PINNING_meta + '</application>');
143
143
  fs.writeFile(manifestFileNewRoot_, result_, 'utf8', function (err) {
144
144
  if (err) {
145
145
  throw new Error('Unable to write into AndroidManifest.xml: ' + err);
146
146
  }
147
147
  });
148
-
148
+
149
149
  }
150
- });
151
- }
152
- catch(err) {
150
+ });
153
151
  }
152
+ catch (err) {
154
153
  }
155
154
  }
156
- }
157
-
158
-
155
+ }
159
156
  }
157
+
158
+
159
+ }