cordova-plugin-appice 2.0.7 → 2.0.8

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 (35) hide show
  1. package/README.md +122 -122
  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 +102 -102
  8. package/libcordova/android-release-aar.gradle +62 -62
  9. package/libcordova/build.gradle +50 -50
  10. package/libcordova/proguard-rules.pro +21 -21
  11. package/libcordova/src/main/AndroidManifest.xml +24 -24
  12. package/libcordova/src/main/java/com/appice/cordova/AppICEPlugin.java +968 -968
  13. package/libcordova/src/main/java/com/appice/cordova/CampaignCampsReceiver.java +95 -95
  14. package/libcordova/src/main/java/com/appice/cordova/NotificationEventService.java +55 -55
  15. package/libcordova/src/main/res/values/strings.xml +3 -3
  16. package/package.json +26 -26
  17. package/plugin.xml +128 -129
  18. package/scripts/BeforeAndroidBuilt.js +126 -112
  19. package/scripts/BeforeIosBuilt.js +38 -38
  20. package/scripts/androidAfterPluginAdd.js +159 -159
  21. package/scripts/androidAfterPluginRm.js +195 -195
  22. package/scripts/iOSAfterPluginAdd.js +98 -98
  23. package/scripts/iOSAfterPluginRm.js +74 -74
  24. package/src/build.gradle +14 -5
  25. package/src/firebase/modified/android/FirebasePluginMessagingService.java +356 -356
  26. package/src/firebase/modified/ios/AppDelegate+FirebasePlugin.m +529 -529
  27. package/src/firebase/modified/modified.iml +10 -10
  28. package/src/firebase/original/android/FirebasePluginMessagingService.java +348 -348
  29. package/src/firebase/original/ios/AppDelegate+FirebasePlugin.m +519 -519
  30. package/src/firebase/original/original.iml +10 -10
  31. package/src/ios/AppDelegate+AppICEPlugin.h +8 -8
  32. package/src/ios/AppDelegate+AppICEPlugin.m +191 -259
  33. package/src/ios/AppICEPlugin.h +90 -90
  34. package/src/ios/AppICEPlugin.m +1062 -1087
  35. package/www/AppICE.js +283 -283
@@ -1,112 +1,126 @@
1
- module.exports = function(context) {
2
- var fs =require ('fs');
3
- var path = require('path');
4
- var shell = require('shelljs');
5
-
6
- var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
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
- 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
-
20
-
21
- var project_properties=path.join(platformRoot,'project.properties');
22
- ///for SSL pinning
23
-
24
-
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
-
36
- if (data.indexOf(serviceTag) == -1) {
37
- var result = data.replace(/<service android:exported="false" android:name="com.ibm.fcmtest.myIntentService">/g,serviceTag);
38
- fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
39
- if (err) {
40
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
41
- }
42
- });
43
-
44
- }
45
- });
46
- } catch(err) {
47
- }
48
- } else{
49
- var manifestFileNewRoot = path.join(platformRoot, 'AndroidManifest.xml');
50
- if (fs.existsSync(manifestFileNewRoot)) {
51
- try {
52
- fs.readFile(manifestFileNewRoot, 'utf8', function (err,data) {
53
- if (err) {
54
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
55
- }
56
- var serviceTag='<service android:exported="true" android:name="com.appice.appicemfppush.AppICEMFPPush">';
57
-
58
- if (data.indexOf(serviceTag) == -1) {
59
- var result = data.replace(/<service android:exported="false" android:name="com.ibm.fcmtest.myIntentService">/g,serviceTag);
60
- fs.writeFile(manifestFileNewRoot, result, 'utf8', function (err) {
61
- if (err) {
62
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
63
- }
64
- });
65
-
66
- }
67
- });
68
- } catch(err) {
69
- }
70
- }
71
- }
72
-
73
- if(fs.existsSync(project_properties)){
74
- try {
75
- fs.readFile(project_properties, 'utf8', function (err,data) {
76
- if (err) {
77
- throw new Error('Unable to find project_properties: ' + err);
78
- }
79
- var modifiedBuildGradle = data ;
80
- });
81
- }
82
- catch(err) {
83
- console.log("project_properties found :",err);
84
- }
85
- }
86
- }
87
-
88
- if(SSL_PINNING === "true"){
89
-
90
- var target_cert_android = path.join(platformRoot, '/app/src/main/assets/');
91
- var target_cert_ios = path.join(platformRootios, appName+'/Resources/');
92
- //checking existing in android
93
- if (fs.existsSync(target_cert_android+'ai_android.pem')) {
94
- try {
95
- shell.rm('-Rf', target_cert_android+'ai_android.pem');
96
- } catch(err) {
97
- }
98
- }
99
-
100
-
101
- //putting files in assest folder for android
102
- var android_Certificate = path.join(root_cert, 'ai_android.pem');
103
- try {
104
- shell.cp('-f', android_Certificate, target_cert_android);
105
- console.log("android_Certificate copied");
106
- } catch(err) {
107
- console.log("android_Certificate Failed");
108
- }
109
-
110
-
111
- }
112
- }
1
+ module.exports = function(context) {
2
+ var fs =require ('fs');
3
+ var path = require('path');
4
+ var shell = require('shelljs');
5
+
6
+ var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
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
+ 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
+
20
+
21
+ var project_properties=path.join(platformRoot,'project.properties');
22
+ ///for SSL pinning
23
+
24
+
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
+ }
84
+ }
85
+ }
86
+
87
+ if(fs.existsSync(project_properties)){
88
+ try {
89
+ fs.readFile(project_properties, 'utf8', function (err,data) {
90
+ if (err) {
91
+ throw new Error('Unable to find project_properties: ' + err);
92
+ }
93
+ var modifiedBuildGradle = data ;
94
+ });
95
+ }
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) {
111
+ }
112
+ }
113
+
114
+
115
+ //putting files in assest folder for android
116
+ var android_Certificate = path.join(root_cert, 'ai_android.pem');
117
+ 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");
122
+ }
123
+
124
+
125
+ }
126
+ }
@@ -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) {
27
- }
28
- }
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");
37
- }
38
- }
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
+ }
28
+ }
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");
37
+ }
38
+ }
39
39
  }
@@ -1,159 +1,159 @@
1
- module.exports = function(context) {
2
- var fs =require ('fs');
3
- var path = require('path');
4
- var shell = require('shelljs');
5
-
6
- var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
7
- var pluginsFirebaseRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-firebasex');
8
- var pluginsAppiceRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-appice');
9
-
10
- const cordovaCommon = context.requireCordovaModule('cordova-common');
11
- const appConfig = new cordovaCommon.ConfigParser('config.xml');
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');
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);
22
- var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
23
- if (fs.existsSync(firebaseFile1)) {
24
- try {
25
- shell.rm('-Rf', firebaseFile1);
26
- } catch(err) {
27
- }
28
- }
29
-
30
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/android/FirebasePluginMessagingService.java');
31
- try {
32
- shell.cp('-f', modifiedFile1, firebaseFile1);
33
- } catch(err) {
34
- }
35
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
36
- if (fs.existsSync(firebaseFile2)) {
37
- try {
38
- shell.rm('-Rf', firebaseFile2);
39
- } catch(err) {
40
- }
41
- }
42
- try {
43
- shell.cp('-f', modifiedFile1, firebaseFile2);
44
- } catch(err) {
45
- }
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
- }
56
- try {
57
- shell.cp('-f', platformwww2, platformwww1);
58
- } catch(err) {
59
- }
60
- ////
61
-
62
- if(APPICE_APPLICATIONCLASS_INCLUDE === "true"){
63
- var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
64
- if (fs.existsSync(manifestFile)) {
65
- try {
66
- fs.readFile(manifestFile, 'utf8', function (err,data) {
67
- if (err) {
68
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
69
- }
70
- var appClass = 'semusi.activitysdk.ContextApplication';
71
- if (data.indexOf(appClass) == -1) {
72
- var result = data.replace(/<application/g, '<application android:name="' + appClass + '"');
73
- fs.writeFile(manifestFile, result, 'utf8', function (err) {
74
- if (err) {
75
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
76
- }
77
- });
78
- }
79
- });
80
- } catch(err) {
81
- }
82
- }
83
- else {
84
- var manifestFileNew = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
85
- if (fs.existsSync(manifestFileNew)) {
86
- try {
87
- fs.readFile(manifestFileNew, 'utf8', function (err,data) {
88
- if (err) {
89
- throw new Error('Unable to find AndroidManifest.xml: ' + err);
90
- }
91
- var appClass = 'semusi.activitysdk.ContextApplication';
92
- if (data.indexOf(appClass) == -1) {
93
- var result = data.replace(/<application/g, '<application android:name="' + appClass + '"');
94
- fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
95
- if (err) {
96
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
97
- }
98
- });
99
- }
100
- });
101
- } catch(err) {
102
- }
103
- }
104
- }
105
- }
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
-
117
- var SSL_PINNING_meta = '\n<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
118
- if (data_.indexOf(SSL_PINNING_meta) == -1) {
119
- var result_ = data_.replace('</application>',SSL_PINNING_meta+'\n</application>');
120
- fs.writeFile(manifestFileNew_, result_, 'utf8', function (err) {
121
- if (err) {
122
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
123
- }
124
- });
125
-
126
- }
127
- });
128
- }
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
- var SSL_PINNING_meta = '<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
141
- if (data_.indexOf(SSL_PINNING_meta) == -1) {
142
- var result_ = data_.replace('</application>',SSL_PINNING_meta+'</application>');
143
- fs.writeFile(manifestFileNewRoot_, result_, 'utf8', function (err) {
144
- if (err) {
145
- throw new Error('Unable to write into AndroidManifest.xml: ' + err);
146
- }
147
- });
148
-
149
- }
150
- });
151
- }
152
- catch(err) {
153
- }
154
- }
155
- }
156
- }
157
-
158
-
159
- }
1
+ module.exports = function(context) {
2
+ var fs =require ('fs');
3
+ var path = require('path');
4
+ var shell = require('shelljs');
5
+
6
+ var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
7
+ var pluginsFirebaseRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-firebasex');
8
+ var pluginsAppiceRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-appice');
9
+
10
+ const cordovaCommon = context.requireCordovaModule('cordova-common');
11
+ const appConfig = new cordovaCommon.ConfigParser('config.xml');
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');
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);
22
+ var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
23
+ if (fs.existsSync(firebaseFile1)) {
24
+ try {
25
+ shell.rm('-Rf', firebaseFile1);
26
+ } catch(err) {
27
+ }
28
+ }
29
+
30
+ var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/android/FirebasePluginMessagingService.java');
31
+ try {
32
+ shell.cp('-f', modifiedFile1, firebaseFile1);
33
+ } catch(err) {
34
+ }
35
+ var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
36
+ if (fs.existsSync(firebaseFile2)) {
37
+ try {
38
+ shell.rm('-Rf', firebaseFile2);
39
+ } catch(err) {
40
+ }
41
+ }
42
+ try {
43
+ shell.cp('-f', modifiedFile1, firebaseFile2);
44
+ } catch(err) {
45
+ }
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
+ }
56
+ try {
57
+ shell.cp('-f', platformwww2, platformwww1);
58
+ } catch(err) {
59
+ }
60
+ ////
61
+
62
+ if(APPICE_APPLICATIONCLASS_INCLUDE === "true"){
63
+ var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
64
+ if (fs.existsSync(manifestFile)) {
65
+ try {
66
+ fs.readFile(manifestFile, 'utf8', function (err,data) {
67
+ if (err) {
68
+ throw new Error('Unable to find AndroidManifest.xml: ' + err);
69
+ }
70
+ var appClass = 'semusi.activitysdk.ContextApplication';
71
+ if (data.indexOf(appClass) == -1) {
72
+ var result = data.replace(/<application/g, '<application android:name="' + appClass + '"');
73
+ fs.writeFile(manifestFile, result, 'utf8', function (err) {
74
+ if (err) {
75
+ throw new Error('Unable to write into AndroidManifest.xml: ' + err);
76
+ }
77
+ });
78
+ }
79
+ });
80
+ } catch(err) {
81
+ }
82
+ }
83
+ else {
84
+ var manifestFileNew = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
85
+ if (fs.existsSync(manifestFileNew)) {
86
+ try {
87
+ fs.readFile(manifestFileNew, 'utf8', function (err,data) {
88
+ if (err) {
89
+ throw new Error('Unable to find AndroidManifest.xml: ' + err);
90
+ }
91
+ var appClass = 'semusi.activitysdk.ContextApplication';
92
+ if (data.indexOf(appClass) == -1) {
93
+ var result = data.replace(/<application/g, '<application android:name="' + appClass + '"');
94
+ fs.writeFile(manifestFileNew, result, 'utf8', function (err) {
95
+ if (err) {
96
+ throw new Error('Unable to write into AndroidManifest.xml: ' + err);
97
+ }
98
+ });
99
+ }
100
+ });
101
+ } catch(err) {
102
+ }
103
+ }
104
+ }
105
+ }
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
+
117
+ var SSL_PINNING_meta = '\n<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
118
+ if (data_.indexOf(SSL_PINNING_meta) == -1) {
119
+ var result_ = data_.replace('</application>',SSL_PINNING_meta+'\n</application>');
120
+ fs.writeFile(manifestFileNew_, result_, 'utf8', function (err) {
121
+ if (err) {
122
+ throw new Error('Unable to write into AndroidManifest.xml: ' + err);
123
+ }
124
+ });
125
+
126
+ }
127
+ });
128
+ }
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
+ var SSL_PINNING_meta = '<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
141
+ if (data_.indexOf(SSL_PINNING_meta) == -1) {
142
+ var result_ = data_.replace('</application>',SSL_PINNING_meta+'</application>');
143
+ fs.writeFile(manifestFileNewRoot_, result_, 'utf8', function (err) {
144
+ if (err) {
145
+ throw new Error('Unable to write into AndroidManifest.xml: ' + err);
146
+ }
147
+ });
148
+
149
+ }
150
+ });
151
+ }
152
+ catch(err) {
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+
159
+ }