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.
- package/README.md +0 -2
- package/example/config.xml +59 -59
- package/example/package.json +38 -38
- package/example/res/ai_android.pem +40 -40
- package/example/www/css/index.css +116 -116
- package/example/www/index.html +62 -62
- package/example/www/js/index.js +111 -102
- package/package.json +20 -2
- package/plugin.xml +193 -128
- package/scripts/BeforeAndroidBuilt.js +165 -102
- package/scripts/BeforeIosBuilt.js +35 -35
- package/scripts/androidAfterPluginAdd.js +67 -67
- package/scripts/androidAfterPluginRm.js +112 -112
- package/scripts/iOSAfterPluginAdd.js +58 -58
- package/scripts/iOSAfterPluginRm.js +30 -31
- package/src/android/AppICEFCMPush.java +26 -0
- package/src/android/AppICEMFPPush.java +67 -0
- package/{libcordova/src/main/java/com/appice/cordova → src/android}/AppICEPlugin.java +984 -968
- package/src/android/AppICEPushHandler.java +163 -0
- package/{libcordova/src/main/java/com/appice/cordova → src/android}/CampaignCampsReceiver.java +94 -95
- package/{libcordova/src/main/java/com/appice/cordova → src/android}/NotificationEventService.java +64 -55
- package/src/build.gradle +4 -2
- package/src/ios/AppDelegate+AppICEPlugin.m +178 -89
- package/src/ios/AppICEPlugin.h +3 -0
- package/src/ios/AppICEPlugin.m +55 -10
- package/www/AppICE.js +261 -228
- package/libcordova/android-release-aar.gradle +0 -63
- package/libcordova/build.gradle +0 -50
- package/libcordova/cordova.jar +0 -0
- package/libcordova/proguard-rules.pro +0 -21
- package/libcordova/src/main/AndroidManifest.xml +0 -24
- package/libcordova/src/main/res/values/strings.xml +0 -3
- package/src/firebase/modified/modified.iml +0 -11
- package/src/firebase/original/original.iml +0 -11
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
module.exports = function(context) {
|
|
3
|
+
module.exports = function (context) {
|
|
4
4
|
|
|
5
|
-
var fs =require
|
|
5
|
+
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
|
-
var shell = require('shelljs');
|
|
8
|
-
|
|
7
|
+
var shell = require('shelljs');
|
|
8
|
+
|
|
9
9
|
var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
|
|
10
10
|
var pluginsFirebaseRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-firebasex');
|
|
11
11
|
var pluginsAppiceRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-appice');
|
|
12
12
|
|
|
13
|
-
const cordovaCommon = context.requireCordovaModule('cordova-common');
|
|
14
|
-
const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
13
|
+
const cordovaCommon = context.requireCordovaModule('cordova-common');
|
|
14
|
+
const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
15
|
+
|
|
16
|
+
var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "android");
|
|
17
|
+
var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "android");
|
|
18
|
+
var MFP_PUSH = appConfig.getPlatformPreference("MFP_PUSH", "android");
|
|
19
|
+
var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "android");
|
|
20
|
+
var project_properties = path.join(platformRoot, 'project.properties');
|
|
21
|
+
var build_gradle = path.join(platformRoot, '/app/build.gradle');
|
|
15
22
|
|
|
16
|
-
var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "android");
|
|
17
|
-
var APPICE_APPLICATIONCLASS_INCLUDE= appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "android");
|
|
18
|
-
var MFP_PUSH=appConfig.getPlatformPreference("MFP_PUSH", "android");
|
|
19
|
-
var SSL_PINNING=appConfig.getPlatformPreference("SSL_PINNING", "android");
|
|
20
|
-
var project_properties=path.join(platformRoot,'project.properties');
|
|
21
|
-
var build_gradle=path.join(platformRoot,'/app/build.gradle');
|
|
22
|
-
|
|
23
23
|
var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
|
|
24
24
|
if (fs.existsSync(firebaseFile1)) {
|
|
25
25
|
try {
|
|
26
26
|
shell.rm('-Rf', firebaseFile1);
|
|
27
|
-
} catch(err) {
|
|
27
|
+
} catch (err) {
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/original/android/FirebasePluginMessagingService.java');
|
|
32
32
|
try {
|
|
33
33
|
shell.cp('-f', modifiedFile1, firebaseFile1);
|
|
34
|
-
} catch(err) {
|
|
34
|
+
} catch (err) {
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
|
|
38
38
|
if (fs.existsSync(firebaseFile2)) {
|
|
39
39
|
try {
|
|
40
40
|
shell.rm('-Rf', firebaseFile2);
|
|
41
|
-
} catch(err) {
|
|
41
|
+
} catch (err) {
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
try {
|
|
46
46
|
shell.cp('-f', modifiedFile1, firebaseFile2);
|
|
47
|
-
} catch(err) {
|
|
47
|
+
} catch (err) {
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
|
|
51
51
|
if (fs.existsSync(manifestFile)) {
|
|
52
52
|
try {
|
|
53
|
-
fs.readFile(manifestFile, 'utf8', function (err,data) {
|
|
53
|
+
fs.readFile(manifestFile, 'utf8', function (err, data) {
|
|
54
54
|
if (err) {
|
|
55
55
|
throw new Error('Unable to find AndroidManifest.xml: ' + err);
|
|
56
56
|
}
|
|
@@ -64,14 +64,14 @@ const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
-
} catch(err) {
|
|
67
|
+
} catch (err) {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
71
|
var manifestFileNew = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
|
|
72
72
|
if (fs.existsSync(manifestFileNew)) {
|
|
73
73
|
try {
|
|
74
|
-
fs.readFile(manifestFileNew, 'utf8', function (err,data) {
|
|
74
|
+
fs.readFile(manifestFileNew, 'utf8', function (err, data) {
|
|
75
75
|
if (err) {
|
|
76
76
|
throw new Error('Unable to find AndroidManifest.xml: ' + err);
|
|
77
77
|
}
|
|
@@ -85,112 +85,112 @@ const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
} catch(err) {
|
|
88
|
+
} catch (err) {
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
//////remove SSL Pinning
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
//////remove SSL Pinning
|
|
94
|
+
var manifestFileNew_ = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
|
|
95
|
+
if (fs.existsSync(manifestFileNew_)) {
|
|
96
|
+
try {
|
|
97
|
+
fs.readFile(manifestFileNew_, 'utf8', function (err, data_) {
|
|
98
|
+
if (err) {
|
|
99
|
+
throw new Error('Unable to find AndroidManifest.xml: ' + err);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var SSL_PINNING_meta = '<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
|
|
103
|
+
|
|
104
|
+
var result_ = data_.replace(SSL_PINNING_meta, ' ');
|
|
105
|
+
|
|
106
|
+
//removing tag
|
|
107
|
+
result_ = result_.replace(/<service android:exported="true" android:name="com.appice.cordova.AppICEMFPPush">/g, '<service android:exported="false" android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNewIntentService">');
|
|
108
|
+
fs.writeFile(manifestFileNew_, result_, 'utf8', function (err) {
|
|
109
|
+
if (err) {
|
|
110
|
+
throw new Error('Unable to write into AndroidManifest.xml: ' + err);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
var manifestFileNewRoot_ = path.join(platformRoot, 'AndroidManifest.xml');
|
|
120
|
+
if (fs.existsSync(manifestFileNewRoot_)) {
|
|
121
|
+
try {
|
|
122
|
+
fs.readFile(manifestFileNewRoot_, 'utf8', function (err, data_) {
|
|
98
123
|
if (err) {
|
|
99
124
|
throw new Error('Unable to find AndroidManifest.xml: ' + err);
|
|
100
125
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var result_ = data_.replace(SSL_PINNING_meta,' ');
|
|
126
|
+
///for SSL pinning
|
|
127
|
+
var SSL_PINNING_meta = '<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
|
|
105
128
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
fs.writeFile(manifestFileNew_, result_, 'utf8', function (err) {
|
|
129
|
+
var result_ = data_.replace(SSL_PINNING_meta, ' ');
|
|
130
|
+
fs.writeFile(manifestFileNewRoot_, result_, 'utf8', function (err) {
|
|
109
131
|
if (err) {
|
|
110
132
|
throw new Error('Unable to write into AndroidManifest.xml: ' + err);
|
|
111
133
|
}
|
|
112
134
|
});
|
|
113
|
-
|
|
135
|
+
|
|
136
|
+
|
|
114
137
|
});
|
|
115
138
|
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
}else{
|
|
119
|
-
var manifestFileNewRoot_ = path.join(platformRoot, 'AndroidManifest.xml');
|
|
120
|
-
if(fs.existsSync(manifestFileNewRoot_)){
|
|
121
|
-
try{
|
|
122
|
-
fs.readFile(manifestFileNewRoot_, 'utf8', function (err,data_) {
|
|
123
|
-
if (err) {
|
|
124
|
-
throw new Error('Unable to find AndroidManifest.xml: ' + err);
|
|
125
|
-
}
|
|
126
|
-
///for SSL pinning
|
|
127
|
-
var SSL_PINNING_meta = '<meta-data android:name="APPICE_SSL_PINNING" android:value="1" />';
|
|
128
|
-
|
|
129
|
-
var result_ = data_.replace(SSL_PINNING_meta,' ');
|
|
130
|
-
fs.writeFile(manifestFileNewRoot_, result_, 'utf8', function (err) {
|
|
131
|
-
if (err) {
|
|
132
|
-
throw new Error('Unable to write into AndroidManifest.xml: ' + err);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
catch(err) {
|
|
140
|
-
}
|
|
139
|
+
catch (err) {
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//////remove from build.gradle
|
|
145
|
+
if (fs.existsSync(build_gradle)) {
|
|
146
|
+
try {
|
|
147
|
+
fs.readFile(build_gradle, 'utf8', function (err, data) {
|
|
148
|
+
if (err) {
|
|
149
|
+
throw new Error('Unable to find build_gradle: ' + err);
|
|
150
|
+
}
|
|
151
|
+
var modifiedBuildGradle = data;
|
|
152
|
+
// var libmfp_prop='cordova.system.library.13=appice.io.android:libmfp:1.0.0'
|
|
153
|
+
//+ '\nimplementation appice.io.android:libmfp:+"';
|
|
154
|
+
var libmfp_prop = 'implementation "appice.io.android:libmfp:1.0.0"'
|
|
155
|
+
|
|
156
|
+
var result__ = data.replace(libmfp_prop, '');
|
|
157
|
+
fs.writeFile(build_gradle, result__, 'utf8', function (err) {
|
|
148
158
|
if (err) {
|
|
149
|
-
throw new Error('Unable to
|
|
159
|
+
throw new Error('Unable to write into AndroidManifest.xml: ' + err);
|
|
150
160
|
}
|
|
151
|
-
var modifiedBuildGradle = data ;
|
|
152
|
-
// var libmfp_prop='cordova.system.library.13=appice.io.android:libmfp:1.0.0'
|
|
153
|
-
//+ '\nimplementation appice.io.android:libmfp:+"';
|
|
154
|
-
var libmfp_prop='implementation "appice.io.android:libmfp:1.0.0"'
|
|
155
|
-
|
|
156
|
-
var result__= data.replace(libmfp_prop,'');
|
|
157
|
-
fs.writeFile(build_gradle, result__, 'utf8', function (err) {
|
|
158
|
-
if (err) {
|
|
159
|
-
throw new Error('Unable to write into AndroidManifest.xml: ' + err);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
161
|
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
console.log("build_gradle found :", err);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
//remove AppICEMFPPush tag
|
|
171
|
+
// var manifestFileNewForMFP = path.join(platformRoot, '/app/src/main/AndroidManifest.xml');
|
|
172
|
+
|
|
173
|
+
// if (fs.existsSync(manifestFileNewForMFP)) {
|
|
174
|
+
// try {
|
|
175
|
+
// fs.readFile(manifestFileNewForMFP, 'utf8', function (err,data) {
|
|
176
|
+
// if (err) {
|
|
177
|
+
// throw new Error('Unable to find AndroidManifest.xml: ' + err);
|
|
178
|
+
// }
|
|
179
|
+
// var serviceTag='<service android:exported="true" android:name="com.appice.cordova.AppICEMFPPush">';
|
|
180
|
+
|
|
181
|
+
// // if (data.indexOf(serviceTag) == -1) {
|
|
182
|
+
// //<service android:exported="false" android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNewIntentService">
|
|
183
|
+
// var result = data.replace(serviceTag,'<service android:exported="false" android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNewIntentService">');
|
|
184
|
+
// fs.writeFile(manifestFileNewForMFP, result, 'utf8', function (err) {
|
|
185
|
+
// if (err) {
|
|
186
|
+
// throw new Error('Unable to write into AndroidManifest.xml: ' + err);
|
|
187
|
+
// }
|
|
188
|
+
// });
|
|
189
|
+
|
|
190
|
+
// // }
|
|
191
|
+
// });
|
|
192
|
+
// } catch(err) {
|
|
193
|
+
// }
|
|
194
|
+
// }
|
|
195
|
+
|
|
196
196
|
}
|
|
@@ -1,98 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
module.exports = function(context) {
|
|
3
|
+
module.exports = function (context) {
|
|
4
4
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var shell = require('shelljs');
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
// var ConfigParser = require("cordova-lib").configparser;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// var config = new ConfigParser("config.xml");
|
|
11
|
+
// var appName = config.name();
|
|
12
|
+
|
|
13
13
|
const cordovaCommon = context.requireCordovaModule('cordova-common');
|
|
14
14
|
const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
15
15
|
const appName = appConfig.name();
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
var platformRoot = path.join(context.opts.projectRoot, 'platforms/ios');
|
|
18
18
|
var pluginsFirebaseRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-firebasex');
|
|
19
19
|
var pluginsAppiceRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-appice');
|
|
20
20
|
|
|
21
21
|
var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "ios");
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "ios");
|
|
23
|
+
var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "ios");
|
|
24
24
|
|
|
25
|
-
////SSL_PINNING
|
|
25
|
+
////SSL_PINNING
|
|
26
26
|
|
|
27
|
-
if(APPICE_FIREBASE_UPDATE === "true"){
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
if (APPICE_FIREBASE_UPDATE === "true") {
|
|
28
|
+
console.log("inside APPICE_FIREBASE_UPDATE : " + appName);
|
|
29
|
+
var firebaseFile1 = path.join(platformRoot, '/' + appName + '/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m');
|
|
30
|
+
if (fs.existsSync(firebaseFile1)) {
|
|
31
|
+
try {
|
|
32
|
+
shell.rm('-Rf', firebaseFile1);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
}
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
shell.cp('-f', modifiedFile1, firebaseFile1);
|
|
40
|
-
} catch(err) {
|
|
41
|
-
}
|
|
42
|
-
var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/ios/AppDelegate+FirebasePlugin.m');
|
|
43
|
-
if (fs.existsSync(firebaseFile2)) {
|
|
37
|
+
var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/ios/AppDelegate+FirebasePlugin.m');
|
|
44
38
|
try {
|
|
45
|
-
shell.
|
|
46
|
-
} catch(err) {
|
|
39
|
+
shell.cp('-f', modifiedFile1, firebaseFile1);
|
|
40
|
+
} catch (err) {
|
|
47
41
|
}
|
|
42
|
+
var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/ios/AppDelegate+FirebasePlugin.m');
|
|
43
|
+
if (fs.existsSync(firebaseFile2)) {
|
|
44
|
+
try {
|
|
45
|
+
shell.rm('-Rf', firebaseFile2);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
shell.cp('-f', modifiedFile1, firebaseFile2);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
console.log("appName : "+appName);
|
|
57
|
-
var get_info_plist=path.join(platformRoot,appName+ '/'+appName+'-Info.plist');
|
|
58
|
-
if(fs.existsSync(get_info_plist)){
|
|
59
|
-
console.log("ssl");
|
|
60
|
-
try{
|
|
61
|
-
fs.readFile(get_info_plist, 'utf8', function (err,data) {
|
|
62
|
-
if (err) {
|
|
63
|
-
throw new Error('Unable to find Plist: ' + err);
|
|
64
|
-
}
|
|
65
|
-
///for SSL pinning
|
|
66
|
-
var SSL_PINNING_key = '<key>APPICE_SSL_PINNING</key>\n<true/>';
|
|
67
|
-
if (data.indexOf(SSL_PINNING_key) == -1) {
|
|
68
|
-
var result = data.replace('</dict>\n</plist>',SSL_PINNING_key+'\n</dict>\n</plist>');
|
|
69
|
-
fs.writeFile(get_info_plist, result, 'utf8', function (err) {
|
|
55
|
+
if (SSL_PINNING === "true") {
|
|
56
|
+
console.log("appName : " + appName);
|
|
57
|
+
var get_info_plist = path.join(platformRoot, appName + '/' + appName + '-Info.plist');
|
|
58
|
+
if (fs.existsSync(get_info_plist)) {
|
|
59
|
+
console.log("ssl");
|
|
60
|
+
try {
|
|
61
|
+
fs.readFile(get_info_plist, 'utf8', function (err, data) {
|
|
70
62
|
if (err) {
|
|
71
|
-
throw new Error('Unable to
|
|
63
|
+
throw new Error('Unable to find Plist: ' + err);
|
|
64
|
+
}
|
|
65
|
+
///for SSL pinning
|
|
66
|
+
var SSL_PINNING_key = '<key>APPICE_SSL_PINNING</key>\n<true/>';
|
|
67
|
+
if (data.indexOf(SSL_PINNING_key) == -1) {
|
|
68
|
+
var result = data.replace('</dict>\n</plist>', SSL_PINNING_key + '\n</dict>\n</plist>');
|
|
69
|
+
fs.writeFile(get_info_plist, result, 'utf8', function (err) {
|
|
70
|
+
if (err) {
|
|
71
|
+
throw new Error('Unable to write into Plist: ' + err);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
72
75
|
}
|
|
73
76
|
});
|
|
74
|
-
|
|
75
77
|
}
|
|
76
|
-
|
|
78
|
+
catch (err) {
|
|
79
|
+
}
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
var platformwww1 = path.join(platformRoot, '/platform_www/plugins/cordova-plugin-appice/www/AppICE.js');
|
|
85
85
|
var platformwww2 = path.join(pluginsAppiceRoot, '/www/AppICE.js');
|
|
86
86
|
if (fs.existsSync(platformwww1)) {
|
|
87
87
|
try {
|
|
88
88
|
shell.rm('-Rf', platformwww1);
|
|
89
|
-
} catch(err) {
|
|
89
|
+
} catch (err) {
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
try {
|
|
93
93
|
shell.cp('-f', platformwww2, platformwww1);
|
|
94
|
-
} catch(err) {
|
|
94
|
+
} catch (err) {
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
|
|
@@ -1,75 +1,74 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
module.exports = function(context) {
|
|
3
|
+
module.exports = function (context) {
|
|
4
4
|
|
|
5
5
|
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var shell = require('shelljs');
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
const cordovaCommon = context.requireCordovaModule('cordova-common');
|
|
10
|
-
const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
11
|
-
|
|
10
|
+
const appConfig = new cordovaCommon.ConfigParser('config.xml');
|
|
11
|
+
var appName = appConfig.name();
|
|
12
12
|
|
|
13
13
|
var platformRoot = path.join(context.opts.projectRoot, 'platforms/ios');
|
|
14
14
|
var pluginsFirebaseRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-firebasex');
|
|
15
15
|
var pluginsAppiceRoot = path.join(context.opts.projectRoot, 'plugins/cordova-plugin-appice');
|
|
16
16
|
var APPICE_FIREBASE_UPDATE = appConfig.getPlatformPreference("APPICE_FIREBASE_UPDATE", "ios");
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "ios");
|
|
18
|
+
var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "ios");
|
|
19
19
|
|
|
20
|
-
var firebaseFile1 = path.join(platformRoot, '/'+appName+'/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m');
|
|
20
|
+
var firebaseFile1 = path.join(platformRoot, '/' + appName + '/Plugins/cordova-plugin-firebasex/AppDelegate+FirebasePlugin.m');
|
|
21
21
|
if (fs.existsSync(firebaseFile1)) {
|
|
22
22
|
try {
|
|
23
23
|
shell.rm('-Rf', firebaseFile1);
|
|
24
|
-
} catch(err) {
|
|
24
|
+
} catch (err) {
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/original/ios/AppDelegate+FirebasePlugin.m');
|
|
29
29
|
try {
|
|
30
30
|
shell.cp('-f', modifiedFile1, firebaseFile1);
|
|
31
|
-
} catch(err) {
|
|
31
|
+
} catch (err) {
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/ios/AppDelegate+FirebasePlugin.m');
|
|
35
35
|
if (fs.existsSync(firebaseFile2)) {
|
|
36
36
|
try {
|
|
37
37
|
shell.rm('-Rf', firebaseFile2);
|
|
38
|
-
} catch(err) {
|
|
38
|
+
} catch (err) {
|
|
39
39
|
}
|
|
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
|
-
if(SSL_PINNING
|
|
48
|
-
console.log("appName : "+appName);
|
|
49
|
-
var get_info_plist=path.join(platformRoot,appName+ '/'+appName+'-Info.plist');
|
|
50
|
-
if(fs.existsSync(get_info_plist)){
|
|
47
|
+
if (SSL_PINNING === "true") {
|
|
48
|
+
console.log("appName : " + appName);
|
|
49
|
+
var get_info_plist = path.join(platformRoot, appName + '/' + appName + '-Info.plist');
|
|
50
|
+
if (fs.existsSync(get_info_plist)) {
|
|
51
51
|
console.log("ssl");
|
|
52
|
-
try{
|
|
53
|
-
fs.readFile(get_info_plist, 'utf8', function (err,data) {
|
|
52
|
+
try {
|
|
53
|
+
fs.readFile(get_info_plist, 'utf8', function (err, data) {
|
|
54
54
|
if (err) {
|
|
55
55
|
throw new Error('Unable to find Plist: ' + err);
|
|
56
56
|
}
|
|
57
57
|
///for removing SSL pinning
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
58
|
+
var SSL_PINNING_key = '<key>APPICE_SSL_PINNING</key>\n<true/>';
|
|
59
|
+
if (data.indexOf(SSL_PINNING_key) == -1) {
|
|
60
|
+
var result = data.replace('APPICE_SSL_PINNING', '');
|
|
61
|
+
fs.writeFile(get_info_plist, result, 'utf8', function (err) {
|
|
62
|
+
if (err) {
|
|
63
|
+
throw new Error('Unable to write into Plist: ' + err);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
69
|
+
catch (err) {
|
|
70
|
+
}
|
|
74
71
|
}
|
|
72
|
+
|
|
73
|
+
}
|
|
75
74
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.appice.cordova;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.google.firebase.messaging.FirebaseMessagingService;
|
|
6
|
+
import com.google.firebase.messaging.RemoteMessage;
|
|
7
|
+
|
|
8
|
+
public class AppICEFCMPush extends FirebaseMessagingService {
|
|
9
|
+
private final AppICEPushHandler appICEPushHandler = new AppICEPushHandler();
|
|
10
|
+
|
|
11
|
+
@Override
|
|
12
|
+
public void onNewToken(@NonNull String token) {
|
|
13
|
+
super.onNewToken(token);
|
|
14
|
+
appICEPushHandler.onNewToken(token, getApplicationContext());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public void onMessageReceived(@NonNull RemoteMessage message) {
|
|
19
|
+
super.onMessageReceived(message);
|
|
20
|
+
if(appICEPushHandler.isAppICEPush(message)) {
|
|
21
|
+
appICEPushHandler.onMessageReceived(message, getApplicationContext());
|
|
22
|
+
}else{
|
|
23
|
+
// handle your customise push payload here
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package com.appice.cordova;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
|
|
7
|
+
import com.google.firebase.messaging.RemoteMessage;
|
|
8
|
+
import com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService;
|
|
9
|
+
import com.ibm.mobilefirstplatform.clientsdk.android.push.internal.MFPInternalPushMessage;
|
|
10
|
+
|
|
11
|
+
import org.json.JSONObject;
|
|
12
|
+
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
|
|
15
|
+
public class AppICEMFPPush extends MFPPushIntentService{
|
|
16
|
+
private static final String TAG = AppICEMFPPush.class.getName();
|
|
17
|
+
private final AppICEPushHandler appICEPushHandler = new AppICEPushHandler();
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public void onMessageReceived(RemoteMessage message) {
|
|
21
|
+
MFPPushIntentService mfpPushIntentService = new MFPPushIntentService();
|
|
22
|
+
int collapseId = -1;
|
|
23
|
+
if (appICEPushHandler.isAppICEPush(message)){
|
|
24
|
+
appICEPushHandler.onMessageReceived(message, getApplicationContext());
|
|
25
|
+
}else {
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* if you have your customise code for MFP push then
|
|
29
|
+
* you can pass this remote message to your custom class
|
|
30
|
+
* rather calling mfpIntent directly
|
|
31
|
+
*
|
|
32
|
+
* you can also extend your custom class
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
// in case if there will no custom class
|
|
36
|
+
Map<String, String> data = message.getData();
|
|
37
|
+
JSONObject payload = null;
|
|
38
|
+
try {
|
|
39
|
+
JSONObject dataPayload = new JSONObject(data);
|
|
40
|
+
if (dataPayload != null) {
|
|
41
|
+
MFPInternalPushMessage recMessage = new MFPInternalPushMessage(dataPayload);
|
|
42
|
+
payload = new JSONObject(recMessage.getPayload());
|
|
43
|
+
if (payload != null && payload.has("collapseId")) {
|
|
44
|
+
collapseId = payload.optInt("collapseId");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} catch (Exception e) {
|
|
48
|
+
Log.e(TAG, "onMessageReceived: error ", e);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
if (collapseId != -1) {
|
|
52
|
+
mfpPushIntentService.onNotificationReceived(data, collapseId);
|
|
53
|
+
} else {
|
|
54
|
+
super.onMessageReceived(message);
|
|
55
|
+
}
|
|
56
|
+
} catch (Exception e) {
|
|
57
|
+
Log.e(TAG, "onMessageReceived: error", e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Override
|
|
63
|
+
public void onNewToken(@NonNull String token) {
|
|
64
|
+
super.onNewToken(token);
|
|
65
|
+
appICEPushHandler.onNewToken(token, getApplicationContext());
|
|
66
|
+
}
|
|
67
|
+
}
|