cordova-plugin-appice 2.1.8 → 2.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-appice",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "AppICE Plugin for Cordova/PhoneGap",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-appice",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
- id="cordova-plugin-appice" version="2.1.8">
3
+ id="cordova-plugin-appice" version="2.1.9">
4
4
  <name>AppICE</name>
5
5
  <description>AppICE Plugin for Cordova/PhoneGap</description>
6
6
  <license>Commercial</license>
@@ -16,34 +16,6 @@ module.exports = function (context) {
16
16
  var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "android");
17
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);
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
19
  //////
48
20
  var platformwww1 = path.join(platformRoot, '/platform_www/plugins/cordova-plugin-appice/www/AppICE.js');
49
21
  var platformwww2 = path.join(pluginsAppiceRoot, '/www/AppICE.js');
@@ -20,33 +20,6 @@ module.exports = function (context) {
20
20
  var project_properties = path.join(platformRoot, 'project.properties');
21
21
  var build_gradle = path.join(platformRoot, '/app/build.gradle');
22
22
 
23
- var firebaseFile1 = path.join(platformRoot, '/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java');
24
- if (fs.existsSync(firebaseFile1)) {
25
- try {
26
- shell.rm('-Rf', firebaseFile1);
27
- } catch (err) {
28
- }
29
- }
30
-
31
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/original/android/FirebasePluginMessagingService.java');
32
- try {
33
- shell.cp('-f', modifiedFile1, firebaseFile1);
34
- } catch (err) {
35
- }
36
-
37
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/android/FirebasePluginMessagingService.java');
38
- if (fs.existsSync(firebaseFile2)) {
39
- try {
40
- shell.rm('-Rf', firebaseFile2);
41
- } catch (err) {
42
- }
43
- }
44
-
45
- try {
46
- shell.cp('-f', modifiedFile1, firebaseFile2);
47
- } catch (err) {
48
- }
49
-
50
23
  var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
51
24
  if (fs.existsSync(manifestFile)) {
52
25
  try {
@@ -23,35 +23,6 @@ module.exports = function (context) {
23
23
  var SSL_PINNING = appConfig.getPlatformPreference("SSL_PINNING", "ios");
24
24
 
25
25
  ////SSL_PINNING
26
-
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
- }
35
- }
36
-
37
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/modified/ios/AppDelegate+FirebasePlugin.m');
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)) {
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
-
54
- }
55
26
  if (SSL_PINNING === "true") {
56
27
  console.log("appName : " + appName);
57
28
  var get_info_plist = path.join(platformRoot, appName + '/' + appName + '-Info.plist');
@@ -17,33 +17,6 @@ module.exports = function (context) {
17
17
  var APPICE_APPLICATIONCLASS_INCLUDE = appConfig.getPlatformPreference("APPICE_APPLICATIONCLASS_INCLUDE", "ios");
18
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');
21
- if (fs.existsSync(firebaseFile1)) {
22
- try {
23
- shell.rm('-Rf', firebaseFile1);
24
- } catch (err) {
25
- }
26
- }
27
-
28
- var modifiedFile1 = path.join(pluginsAppiceRoot, '/src/firebase/original/ios/AppDelegate+FirebasePlugin.m');
29
- try {
30
- shell.cp('-f', modifiedFile1, firebaseFile1);
31
- } catch (err) {
32
- }
33
-
34
- var firebaseFile2 = path.join(pluginsFirebaseRoot, '/src/ios/AppDelegate+FirebasePlugin.m');
35
- if (fs.existsSync(firebaseFile2)) {
36
- try {
37
- shell.rm('-Rf', firebaseFile2);
38
- } catch (err) {
39
- }
40
- }
41
-
42
- try {
43
- shell.cp('-f', modifiedFile1, firebaseFile2);
44
- } catch (err) {
45
- }
46
-
47
20
  if (SSL_PINNING === "true") {
48
21
  console.log("appName : " + appName);
49
22
  var get_info_plist = path.join(platformRoot, appName + '/' + appName + '-Info.plist');
@@ -1,356 +0,0 @@
1
- package org.apache.cordova.firebase;
2
-
3
- import android.app.NotificationChannel;
4
- import android.app.NotificationManager;
5
- import android.app.PendingIntent;
6
- import android.content.Context;
7
- import android.content.Intent;
8
- import android.graphics.BitmapFactory;
9
- import android.media.RingtoneManager;
10
- import android.net.Uri;
11
- import android.os.Build;
12
- import android.os.Bundle;
13
- import androidx.core.app.NotificationCompat;
14
- import android.util.Log;
15
- import android.app.Notification;
16
- import android.text.TextUtils;
17
- import android.content.ContentResolver;
18
- import android.graphics.Color;
19
- import semusi.activitysdk.ContextSdk;
20
-
21
- import com.google.firebase.crashlytics.FirebaseCrashlytics;
22
- import com.google.firebase.messaging.FirebaseMessagingService;
23
- import com.google.firebase.messaging.RemoteMessage;
24
-
25
- import java.util.Map;
26
- import java.util.Random;
27
-
28
- public class FirebasePluginMessagingService extends FirebaseMessagingService {
29
-
30
- private static final String TAG = "FirebasePlugin";
31
-
32
- static final String defaultSmallIconName = "notification_icon";
33
- static final String defaultLargeIconName = "notification_icon_large";
34
-
35
-
36
- /**
37
- * Called if InstanceID token is updated. This may occur if the security of
38
- * the previous token had been compromised. Note that this is called when the InstanceID token
39
- * is initially generated so this is where you would retrieve the token.
40
- */
41
- @Override
42
- public void onNewToken(String refreshedToken) {
43
- try{
44
- super.onNewToken(refreshedToken);
45
- Log.d(TAG, "Refreshed token: " + refreshedToken);
46
- FirebasePlugin.sendToken(refreshedToken);
47
- }catch (Exception e){
48
- FirebasePlugin.handleExceptionWithoutContext(e);
49
- }
50
- }
51
-
52
-
53
- /**
54
- * Called when message is received.
55
- * Called IF message is a data message (i.e. NOT sent from Firebase console)
56
- * OR if message is a notification message (e.g. sent from Firebase console) AND app is in foreground.
57
- * Notification messages received while app is in background will not be processed by this method;
58
- * they are handled internally by the OS.
59
- *
60
- * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
61
- */
62
- @Override
63
- public void onMessageReceived(RemoteMessage remoteMessage) {
64
- try{
65
- // [START_EXCLUDE]
66
- // There are two types of messages data messages and notification messages. Data messages are handled
67
- // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
68
- // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
69
- // is in the foreground. When the app is in the background an automatically generated notification is displayed.
70
- // When the user taps on the notification they are returned to the app. Messages containing both notification
71
- // and data payloads are treated as notification messages. The Firebase console always sends notification
72
- // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
73
- // [END_EXCLUDE]
74
-
75
- // Pass the message to the receiver manager so any registered receivers can decide to handle it
76
- boolean wasHandled = FirebasePluginMessageReceiverManager.onMessageReceived(remoteMessage);
77
- if (wasHandled) {
78
- Log.d(TAG, "Message was handled by a registered receiver");
79
-
80
- // Don't process the message in this method.
81
- return;
82
- }
83
-
84
- if(FirebasePlugin.applicationContext == null){
85
- FirebasePlugin.applicationContext = this.getApplicationContext();
86
- }
87
-
88
- // TODO(developer): Handle FCM messages here.
89
- // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
90
- String messageType;
91
- String title = null;
92
- String body = null;
93
- String id = null;
94
- String sound = null;
95
- String vibrate = null;
96
- String light = null;
97
- String color = null;
98
- String icon = null;
99
- String channelId = null;
100
- String visibility = null;
101
- String priority = null;
102
- boolean foregroundNotification = false;
103
-
104
- Map<String, String> data = remoteMessage.getData();
105
-
106
- if (remoteMessage.getNotification() != null) {
107
- // Notification message payload
108
- Log.i(TAG, "Received message: notification");
109
- messageType = "notification";
110
- id = remoteMessage.getMessageId();
111
- RemoteMessage.Notification notification = remoteMessage.getNotification();
112
- title = notification.getTitle();
113
- body = notification.getBody();
114
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
115
- channelId = notification.getChannelId();
116
- }
117
- sound = notification.getSound();
118
- color = notification.getColor();
119
- icon = notification.getIcon();
120
- }else{
121
- Log.i(TAG, "Received message: data");
122
- messageType = "data";
123
- }
124
-
125
- if (data != null) {
126
- // Data message payload
127
- if(data.containsKey("notification_foreground")){
128
- foregroundNotification = true;
129
- }
130
- if(data.containsKey("notification_title")) title = data.get("notification_title");
131
- if(data.containsKey("notification_body")) body = data.get("notification_body");
132
- if(data.containsKey("notification_android_channel_id")) channelId = data.get("notification_android_channel_id");
133
- if(data.containsKey("notification_android_id")) id = data.get("notification_android_id");
134
- if(data.containsKey("notification_android_sound")) sound = data.get("notification_android_sound");
135
- if(data.containsKey("notification_android_vibrate")) vibrate = data.get("notification_android_vibrate");
136
- if(data.containsKey("notification_android_light")) light = data.get("notification_android_light"); //String containing hex ARGB color, miliseconds on, miliseconds off, example: '#FFFF00FF,1000,3000'
137
- if(data.containsKey("notification_android_color")) color = data.get("notification_android_color");
138
- if(data.containsKey("notification_android_icon")) icon = data.get("notification_android_icon");
139
- if(data.containsKey("notification_android_visibility")) visibility = data.get("notification_android_visibility");
140
- if(data.containsKey("notification_android_priority")) priority = data.get("notification_android_priority");
141
- }
142
-
143
- if (TextUtils.isEmpty(id)) {
144
- Random rand = new Random();
145
- int n = rand.nextInt(50) + 1;
146
- id = Integer.toString(n);
147
- }
148
-
149
- Log.d(TAG, "From: " + remoteMessage.getFrom());
150
- Log.d(TAG, "Id: " + id);
151
- Log.d(TAG, "Title: " + title);
152
- Log.d(TAG, "Body: " + body);
153
- Log.d(TAG, "Sound: " + sound);
154
- Log.d(TAG, "Vibrate: " + vibrate);
155
- Log.d(TAG, "Light: " + light);
156
- Log.d(TAG, "Color: " + color);
157
- Log.d(TAG, "Icon: " + icon);
158
- Log.d(TAG, "Channel Id: " + channelId);
159
- Log.d(TAG, "Visibility: " + visibility);
160
- Log.d(TAG, "Priority: " + priority);
161
-
162
-
163
- if (!TextUtils.isEmpty(body) || !TextUtils.isEmpty(title) || (data != null && !data.isEmpty())) {
164
- boolean showNotification = (FirebasePlugin.inBackground() || !FirebasePlugin.hasNotificationsCallback() || foregroundNotification) && (!TextUtils.isEmpty(body) || !TextUtils.isEmpty(title));
165
- sendMessage(remoteMessage, data, messageType, id, title, body, showNotification, sound, vibrate, light, color, icon, channelId, priority, visibility);
166
- }
167
- try {
168
- // AppICE - passing notification payload to appcie layer
169
- ContextSdk.handleAppICEPush(remoteMessage,this.getApplicationContext());
170
-
171
- } catch (Exception e) {
172
- e.printStackTrace();
173
- }
174
- }catch (Exception e){
175
- FirebasePlugin.handleExceptionWithoutContext(e);
176
- }
177
- }
178
-
179
- private void sendMessage(RemoteMessage remoteMessage, Map<String, String> data, String messageType, String id, String title, String body, boolean showNotification, String sound, String vibrate, String light, String color, String icon, String channelId, String priority, String visibility) {
180
- Log.d(TAG, "sendMessage(): messageType="+messageType+"; showNotification="+showNotification+"; id="+id+"; title="+title+"; body="+body+"; sound="+sound+"; vibrate="+vibrate+"; light="+light+"; color="+color+"; icon="+icon+"; channel="+channelId+"; data="+data.toString());
181
- Bundle bundle = new Bundle();
182
- for (String key : data.keySet()) {
183
- bundle.putString(key, data.get(key));
184
- }
185
- bundle.putString("messageType", messageType);
186
- this.putKVInBundle("id", id, bundle);
187
- this.putKVInBundle("title", title, bundle);
188
- this.putKVInBundle("body", body, bundle);
189
- this.putKVInBundle("sound", sound, bundle);
190
- this.putKVInBundle("vibrate", vibrate, bundle);
191
- this.putKVInBundle("light", light, bundle);
192
- this.putKVInBundle("color", color, bundle);
193
- this.putKVInBundle("icon", icon, bundle);
194
- this.putKVInBundle("channel_id", channelId, bundle);
195
- this.putKVInBundle("priority", priority, bundle);
196
- this.putKVInBundle("visibility", visibility, bundle);
197
- this.putKVInBundle("show_notification", String.valueOf(showNotification), bundle);
198
- this.putKVInBundle("from", remoteMessage.getFrom(), bundle);
199
- this.putKVInBundle("collapse_key", remoteMessage.getCollapseKey(), bundle);
200
- this.putKVInBundle("sent_time", String.valueOf(remoteMessage.getSentTime()), bundle);
201
- this.putKVInBundle("ttl", String.valueOf(remoteMessage.getTtl()), bundle);
202
-
203
- if (showNotification) {
204
- Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
205
- intent.putExtras(bundle);
206
- PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
207
-
208
- // Channel
209
- if(channelId == null || !FirebasePlugin.channelExists(channelId)){
210
- channelId = FirebasePlugin.defaultChannelId;
211
- }
212
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
213
- Log.d(TAG, "Channel ID: "+channelId);
214
- }
215
-
216
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
217
- notificationBuilder
218
- .setContentTitle(title)
219
- .setContentText(body)
220
- .setStyle(new NotificationCompat.BigTextStyle().bigText(body))
221
- .setAutoCancel(true)
222
- .setContentIntent(pendingIntent);
223
-
224
- // On Android O+ the sound/lights/vibration are determined by the channel ID
225
- if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O){
226
- // Sound
227
- if (sound == null) {
228
- Log.d(TAG, "Sound: none");
229
- }else if (sound.equals("default")) {
230
- notificationBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
231
- Log.d(TAG, "Sound: default");
232
- }else{
233
- Uri soundPath = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/" + sound);
234
- Log.d(TAG, "Sound: custom=" + sound+"; path="+soundPath.toString());
235
- notificationBuilder.setSound(soundPath);
236
- }
237
-
238
- // Light
239
- if (light != null) {
240
- try {
241
- String[] lightsComponents = color.replaceAll("\\s", "").split(",");
242
- if (lightsComponents.length == 3) {
243
- int lightArgb = Color.parseColor(lightsComponents[0]);
244
- int lightOnMs = Integer.parseInt(lightsComponents[1]);
245
- int lightOffMs = Integer.parseInt(lightsComponents[2]);
246
- notificationBuilder.setLights(lightArgb, lightOnMs, lightOffMs);
247
- Log.d(TAG, "Lights: color="+lightsComponents[0]+"; on(ms)="+lightsComponents[2]+"; off(ms)="+lightsComponents[3]);
248
- }
249
-
250
- } catch (Exception e) {}
251
- }
252
-
253
- // Vibrate
254
- if (vibrate != null){
255
- try {
256
- String[] sVibrations = vibrate.replaceAll("\\s", "").split(",");
257
- long[] lVibrations = new long[sVibrations.length];
258
- int i=0;
259
- for(String sVibration: sVibrations){
260
- lVibrations[i] = Integer.parseInt(sVibration.trim());
261
- i++;
262
- }
263
- notificationBuilder.setVibrate(lVibrations);
264
- Log.d(TAG, "Vibrate: "+vibrate);
265
- } catch (Exception e) {
266
- Log.e(TAG, e.getMessage());
267
- }
268
- }
269
- }
270
-
271
-
272
- // Icon
273
- int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
274
- int customSmallIconResID = 0;
275
- if(icon != null){
276
- customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
277
- }
278
-
279
- if (customSmallIconResID != 0) {
280
- notificationBuilder.setSmallIcon(customSmallIconResID);
281
- Log.d(TAG, "Small icon: custom="+icon);
282
- }else if (defaultSmallIconResID != 0) {
283
- Log.d(TAG, "Small icon: default="+defaultSmallIconName);
284
- notificationBuilder.setSmallIcon(defaultSmallIconResID);
285
- } else {
286
- Log.d(TAG, "Small icon: application");
287
- notificationBuilder.setSmallIcon(getApplicationInfo().icon);
288
- }
289
-
290
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
291
- int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
292
- int customLargeIconResID = 0;
293
- if(icon != null){
294
- customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
295
- }
296
-
297
- int largeIconResID;
298
- if (customLargeIconResID != 0 || defaultLargeIconResID != 0) {
299
- if (customLargeIconResID != 0) {
300
- largeIconResID = customLargeIconResID;
301
- Log.d(TAG, "Large icon: custom="+icon);
302
- }else{
303
- Log.d(TAG, "Large icon: default="+defaultLargeIconName);
304
- largeIconResID = defaultLargeIconResID;
305
- }
306
- notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), largeIconResID));
307
- }
308
- }
309
-
310
- // Color
311
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
312
- int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
313
- if(color != null){
314
- notificationBuilder.setColor(Color.parseColor(color));
315
- Log.d(TAG, "Color: custom="+color);
316
- }else{
317
- Log.d(TAG, "Color: default");
318
- notificationBuilder.setColor(defaultColor);
319
- }
320
- }
321
-
322
- // Visibility
323
- int iVisibility = NotificationCompat.VISIBILITY_PUBLIC;
324
- if(visibility != null){
325
- iVisibility = Integer.parseInt(visibility);
326
- }
327
- Log.d(TAG, "Visibility: " + iVisibility);
328
- notificationBuilder.setVisibility(iVisibility);
329
-
330
- // Priority
331
- int iPriority = NotificationCompat.PRIORITY_MAX;
332
- if(priority != null){
333
- iPriority = Integer.parseInt(priority);
334
- }
335
- Log.d(TAG, "Priority: " + iPriority);
336
- notificationBuilder.setPriority(iPriority);
337
-
338
-
339
- // Build notification
340
- Notification notification = notificationBuilder.build();
341
-
342
- // Display notification
343
- NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
344
- Log.d(TAG, "show notification: "+notification.toString());
345
- notificationManager.notify(id.hashCode(), notification);
346
- }
347
- // Send to plugin
348
- FirebasePlugin.sendMessage(bundle, this.getApplicationContext());
349
- }
350
-
351
- private void putKVInBundle(String k, String v, Bundle b){
352
- if(v != null && !b.containsKey(k)){
353
- b.putString(k, v);
354
- }
355
- }
356
- }