pushwoosh-cordova-plugin 8.3.34 → 8.3.35
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/.github/ISSUE_TEMPLATE/bug_report.yml +1 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/plugin.xml +9 -9
- package/src/android/android.iml +11 -0
- package/src/android/src/com/pushwoosh/plugin/pushnotifications/InboxUiStyleManager.java +5 -4
- package/src/android/src/com/pushwoosh/plugin/pushnotifications/PushNotifications.java +202 -187
- package/src/ios/PushNotification.m +58 -0
- package/types/PushNotification.d.ts +5 -0
- package/www/PushNotification.js +30 -0
|
@@ -58,6 +58,7 @@ body:
|
|
|
58
58
|
label: Your Pushwoosh Cordova plugin version
|
|
59
59
|
description: Your version of the Cordova plugin integrated into the application. You may find it on the [releases page](https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/releases)
|
|
60
60
|
options:
|
|
61
|
+
- 8.3.35
|
|
61
62
|
- 8.3.34
|
|
62
63
|
- 8.3.33
|
|
63
64
|
- 8.3.28
|
package/README.md
CHANGED
|
@@ -14,13 +14,13 @@ Cross-Platform push notifications by Pushwoosh for Cordova / PhoneGap
|
|
|
14
14
|
Using npm:
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
cordova plugin add pushwoosh-cordova-plugin@8.3.
|
|
17
|
+
cordova plugin add pushwoosh-cordova-plugin@8.3.35
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Using git:
|
|
21
21
|
|
|
22
22
|
```
|
|
23
|
-
cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.
|
|
23
|
+
cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.3.35
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Guide
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pushwoosh-cordova-plugin",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.35",
|
|
4
4
|
"description": "\n This plugin allows you to send and receive push notifications. Powered by Pushwoosh (www.pushwoosh.com).\n ",
|
|
5
5
|
"main":"www/PushNotification.js",
|
|
6
6
|
"typings":"types/index.d.ts",
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="pushwoosh-cordova-plugin" version="8.3.
|
|
2
|
+
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="pushwoosh-cordova-plugin" version="8.3.35">
|
|
3
3
|
|
|
4
4
|
<name>Pushwoosh</name>
|
|
5
5
|
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
<framework src="com.github.bumptech.glide:glide:4.10.0" />
|
|
78
78
|
<framework src="org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60" />
|
|
79
79
|
|
|
80
|
-
<framework src="com.pushwoosh:pushwoosh:6.7.
|
|
81
|
-
<framework src="com.pushwoosh:pushwoosh-amazon:6.7.
|
|
82
|
-
<framework src="com.pushwoosh:pushwoosh-firebase:6.7.
|
|
83
|
-
<framework src="com.pushwoosh:pushwoosh-badge:6.7.
|
|
84
|
-
<framework src="com.pushwoosh:pushwoosh-inbox:6.7.
|
|
85
|
-
<framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.
|
|
86
|
-
<framework src="com.pushwoosh:pushwoosh-huawei:6.7.
|
|
80
|
+
<framework src="com.pushwoosh:pushwoosh:6.7.16"/>
|
|
81
|
+
<framework src="com.pushwoosh:pushwoosh-amazon:6.7.16"/>
|
|
82
|
+
<framework src="com.pushwoosh:pushwoosh-firebase:6.7.16"/>
|
|
83
|
+
<framework src="com.pushwoosh:pushwoosh-badge:6.7.16"/>
|
|
84
|
+
<framework src="com.pushwoosh:pushwoosh-inbox:6.7.16"/>
|
|
85
|
+
<framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.16"/>
|
|
86
|
+
<framework src="com.pushwoosh:pushwoosh-huawei:6.7.16"/>
|
|
87
87
|
</platform>
|
|
88
88
|
|
|
89
89
|
<!-- ios -->
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
<source url="https://github.com/CocoaPods/Specs.git"/>
|
|
126
126
|
</config>
|
|
127
127
|
<pods use-frameworks="true">
|
|
128
|
-
<pod name="PushwooshXCFramework" spec="6.7.
|
|
128
|
+
<pod name="PushwooshXCFramework" spec="6.7.11" />
|
|
129
129
|
<pod name="PushwooshInboxUIXCFramework" spec="6.1.2" />
|
|
130
130
|
</pods>
|
|
131
131
|
</podspec>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$">
|
|
6
|
+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
7
|
+
</content>
|
|
8
|
+
<orderEntry type="inheritedJdk" />
|
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
+
</component>
|
|
11
|
+
</module>
|
|
@@ -50,8 +50,9 @@ class InboxUiStyleManager {
|
|
|
50
50
|
|
|
51
51
|
private Integer optColor(String key, Integer defaultValue) {
|
|
52
52
|
Integer color = parseColor(style.optString(key));
|
|
53
|
-
if (color == null)
|
|
53
|
+
if (color == null) {
|
|
54
54
|
return defaultValue;
|
|
55
|
+
}
|
|
55
56
|
return color;
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -84,8 +85,7 @@ class InboxUiStyleManager {
|
|
|
84
85
|
if (imagePath != null && imagePath.length() != 0) {
|
|
85
86
|
try {
|
|
86
87
|
return getDrawable(imagePath);
|
|
87
|
-
}
|
|
88
|
-
catch (IOException e) {
|
|
88
|
+
} catch (IOException e) {
|
|
89
89
|
e.printStackTrace();
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -129,8 +129,9 @@ class InboxUiStyleManager {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
public static void setStyle(Context context, JSONObject styleObject) {
|
|
132
|
-
if (styleObject != null)
|
|
132
|
+
if (styleObject != null) {
|
|
133
133
|
new StyleParser(context, styleObject).parse();
|
|
134
|
+
}
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
}
|
|
@@ -111,8 +111,9 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
private JSONObject getPushFromIntent(Intent intent) {
|
|
114
|
-
if (null == intent)
|
|
114
|
+
if (null == intent) {
|
|
115
115
|
return null;
|
|
116
|
+
}
|
|
116
117
|
|
|
117
118
|
if (intent.hasExtra(Pushwoosh.PUSH_RECEIVE_EVENT)) {
|
|
118
119
|
String pushString = intent.getExtras().getString(Pushwoosh.PUSH_RECEIVE_EVENT);
|
|
@@ -224,15 +225,11 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
@CordovaMethod
|
|
227
|
-
private boolean setLanguage(JSONArray data, final CallbackContext callbackContext)
|
|
228
|
-
|
|
229
|
-
try
|
|
230
|
-
{
|
|
228
|
+
private boolean setLanguage(JSONArray data, final CallbackContext callbackContext) {
|
|
229
|
+
try {
|
|
231
230
|
String language = data.getString(0);
|
|
232
231
|
Pushwoosh.getInstance().setLanguage(language);
|
|
233
|
-
}
|
|
234
|
-
catch (JSONException e)
|
|
235
|
-
{
|
|
232
|
+
} catch (JSONException e) {
|
|
236
233
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
237
234
|
}
|
|
238
235
|
return true;
|
|
@@ -240,13 +237,10 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
240
237
|
|
|
241
238
|
@CordovaMethod
|
|
242
239
|
private boolean setShowPushnotificationAlert(JSONArray data, final CallbackContext callbackContext) {
|
|
243
|
-
try
|
|
244
|
-
{
|
|
240
|
+
try {
|
|
245
241
|
boolean showAlert = data.getBoolean(0);
|
|
246
242
|
Pushwoosh.getInstance().setShowPushnotificationAlert(showAlert);
|
|
247
|
-
}
|
|
248
|
-
catch (JSONException e)
|
|
249
|
-
{
|
|
243
|
+
} catch (JSONException e) {
|
|
250
244
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
251
245
|
}
|
|
252
246
|
return true;
|
|
@@ -271,9 +265,9 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
271
265
|
return;
|
|
272
266
|
}
|
|
273
267
|
|
|
274
|
-
if(result.isSuccess()){
|
|
268
|
+
if(result.isSuccess()) {
|
|
275
269
|
callback.success(new JSONObject());
|
|
276
|
-
} else if(result.getException()!=null){
|
|
270
|
+
} else if(result.getException()!=null) {
|
|
277
271
|
callback.error(result.getException().getMessage());
|
|
278
272
|
}
|
|
279
273
|
|
|
@@ -292,8 +286,9 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
292
286
|
@Override
|
|
293
287
|
public void process(@NonNull final Result<TagsBundle, GetTagsException> result) {
|
|
294
288
|
CallbackContext callback = callbackIds.get("getTags");
|
|
295
|
-
if (callback == null)
|
|
289
|
+
if (callback == null) {
|
|
296
290
|
return;
|
|
291
|
+
}
|
|
297
292
|
|
|
298
293
|
if(result.isSuccess()) {
|
|
299
294
|
callback.success(result.getData().toJson());
|
|
@@ -319,21 +314,16 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
319
314
|
}
|
|
320
315
|
|
|
321
316
|
@CordovaMethod
|
|
322
|
-
private boolean createLocalNotification(JSONArray data, final CallbackContext callbackContext)
|
|
323
|
-
{
|
|
317
|
+
private boolean createLocalNotification(JSONArray data, final CallbackContext callbackContext) {
|
|
324
318
|
JSONObject params = null;
|
|
325
|
-
try
|
|
326
|
-
{
|
|
319
|
+
try {
|
|
327
320
|
params = data.getJSONObject(0);
|
|
328
|
-
}
|
|
329
|
-
catch (JSONException e)
|
|
330
|
-
{
|
|
321
|
+
} catch (JSONException e) {
|
|
331
322
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
332
323
|
return false;
|
|
333
324
|
}
|
|
334
325
|
|
|
335
|
-
try
|
|
336
|
-
{
|
|
326
|
+
try {
|
|
337
327
|
//config params: {msg:"message", seconds:30, userData:"optional"}
|
|
338
328
|
String message = params.getString("msg");
|
|
339
329
|
int seconds = params.getInt("seconds");
|
|
@@ -352,9 +342,7 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
352
342
|
.setExtras(extras)
|
|
353
343
|
.build();
|
|
354
344
|
Pushwoosh.getInstance().scheduleLocalNotification(notification);
|
|
355
|
-
}
|
|
356
|
-
catch (JSONException e)
|
|
357
|
-
{
|
|
345
|
+
} catch (JSONException e) {
|
|
358
346
|
PWLog.error(TAG, "Not correct parameters passed (missing parameters)", e);
|
|
359
347
|
return false;
|
|
360
348
|
}
|
|
@@ -363,15 +351,13 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
363
351
|
}
|
|
364
352
|
|
|
365
353
|
@CordovaMethod
|
|
366
|
-
private boolean clearLocalNotification(JSONArray data, final CallbackContext callbackContext)
|
|
367
|
-
{
|
|
354
|
+
private boolean clearLocalNotification(JSONArray data, final CallbackContext callbackContext) {
|
|
368
355
|
LocalNotificationReceiver.cancelAll();
|
|
369
356
|
return true;
|
|
370
357
|
}
|
|
371
358
|
|
|
372
359
|
@CordovaMethod
|
|
373
|
-
private boolean getLaunchNotification(JSONArray data, final CallbackContext callbackContext)
|
|
374
|
-
{
|
|
360
|
+
private boolean getLaunchNotification(JSONArray data, final CallbackContext callbackContext) {
|
|
375
361
|
PushMessage launchNotification = Pushwoosh.getInstance().getLaunchNotification();
|
|
376
362
|
if (launchNotification == null) {
|
|
377
363
|
callbackContext.success((String) null);
|
|
@@ -382,39 +368,33 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
382
368
|
}
|
|
383
369
|
|
|
384
370
|
@CordovaMethod
|
|
385
|
-
private boolean clearLaunchNotification(JSONArray data, final CallbackContext callbackContext)
|
|
386
|
-
{
|
|
371
|
+
private boolean clearLaunchNotification(JSONArray data, final CallbackContext callbackContext) {
|
|
387
372
|
Pushwoosh.getInstance().clearLaunchNotification();
|
|
388
373
|
return true;
|
|
389
374
|
}
|
|
390
375
|
|
|
391
376
|
@CordovaMethod
|
|
392
|
-
private boolean setMultiNotificationMode(JSONArray data, final CallbackContext callbackContext)
|
|
393
|
-
{
|
|
377
|
+
private boolean setMultiNotificationMode(JSONArray data, final CallbackContext callbackContext) {
|
|
394
378
|
PushwooshNotificationSettings.setMultiNotificationMode(true);
|
|
395
379
|
return true;
|
|
396
380
|
}
|
|
397
381
|
|
|
398
382
|
@CordovaMethod
|
|
399
|
-
private boolean setSingleNotificationMode(JSONArray data, final CallbackContext callbackContext)
|
|
400
|
-
{
|
|
383
|
+
private boolean setSingleNotificationMode(JSONArray data, final CallbackContext callbackContext) {
|
|
401
384
|
PushwooshNotificationSettings.setMultiNotificationMode(false);
|
|
402
385
|
return true;
|
|
403
386
|
}
|
|
404
387
|
|
|
405
388
|
@CordovaMethod
|
|
406
|
-
private boolean setSoundType(JSONArray data, final CallbackContext callbackContext)
|
|
407
|
-
|
|
408
|
-
try
|
|
409
|
-
{
|
|
389
|
+
private boolean setSoundType(JSONArray data, final CallbackContext callbackContext) {
|
|
390
|
+
try {
|
|
410
391
|
Integer type = (Integer) data.get(0);
|
|
411
|
-
if (type == null)
|
|
392
|
+
if (type == null) {
|
|
412
393
|
return false;
|
|
394
|
+
}
|
|
413
395
|
|
|
414
396
|
PushwooshNotificationSettings.setSoundNotificationType(SoundType.fromInt(type));
|
|
415
|
-
}
|
|
416
|
-
catch (Exception e)
|
|
417
|
-
{
|
|
397
|
+
} catch (Exception e) {
|
|
418
398
|
PWLog.error(TAG, "No sound parameters passed (missing parameters)", e);
|
|
419
399
|
return false;
|
|
420
400
|
}
|
|
@@ -423,18 +403,15 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
423
403
|
}
|
|
424
404
|
|
|
425
405
|
@CordovaMethod
|
|
426
|
-
private boolean setVibrateType(JSONArray data, final CallbackContext callbackContext)
|
|
427
|
-
|
|
428
|
-
try
|
|
429
|
-
{
|
|
406
|
+
private boolean setVibrateType(JSONArray data, final CallbackContext callbackContext) {
|
|
407
|
+
try {
|
|
430
408
|
Integer type = (Integer) data.get(0);
|
|
431
|
-
if (type == null)
|
|
409
|
+
if (type == null) {
|
|
432
410
|
return false;
|
|
411
|
+
}
|
|
433
412
|
|
|
434
413
|
PushwooshNotificationSettings.setVibrateNotificationType(VibrateType.fromInt(type));
|
|
435
|
-
}
|
|
436
|
-
catch (Exception e)
|
|
437
|
-
{
|
|
414
|
+
} catch (Exception e) {
|
|
438
415
|
PWLog.error(TAG, "No vibration parameters passed (missing parameters)", e);
|
|
439
416
|
return false;
|
|
440
417
|
}
|
|
@@ -443,15 +420,11 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
443
420
|
}
|
|
444
421
|
|
|
445
422
|
@CordovaMethod
|
|
446
|
-
private boolean setLightScreenOnNotification(JSONArray data, final CallbackContext callbackContext)
|
|
447
|
-
|
|
448
|
-
try
|
|
449
|
-
{
|
|
423
|
+
private boolean setLightScreenOnNotification(JSONArray data, final CallbackContext callbackContext) {
|
|
424
|
+
try {
|
|
450
425
|
boolean type = (boolean) data.getBoolean(0);
|
|
451
426
|
PushwooshNotificationSettings.setLightScreenOnNotification(type);
|
|
452
|
-
}
|
|
453
|
-
catch (Exception e)
|
|
454
|
-
{
|
|
427
|
+
} catch (Exception e) {
|
|
455
428
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
456
429
|
return false;
|
|
457
430
|
}
|
|
@@ -460,15 +433,11 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
460
433
|
}
|
|
461
434
|
|
|
462
435
|
@CordovaMethod
|
|
463
|
-
private boolean setEnableLED(JSONArray data, final CallbackContext callbackContext)
|
|
464
|
-
|
|
465
|
-
try
|
|
466
|
-
{
|
|
436
|
+
private boolean setEnableLED(JSONArray data, final CallbackContext callbackContext) {
|
|
437
|
+
try {
|
|
467
438
|
boolean type = (boolean) data.getBoolean(0);
|
|
468
439
|
PushwooshNotificationSettings.setEnableLED(type);
|
|
469
|
-
}
|
|
470
|
-
catch (Exception e)
|
|
471
|
-
{
|
|
440
|
+
} catch (Exception e) {
|
|
472
441
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
473
442
|
return false;
|
|
474
443
|
}
|
|
@@ -477,19 +446,16 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
477
446
|
}
|
|
478
447
|
|
|
479
448
|
@CordovaMethod
|
|
480
|
-
private boolean setColorLED(JSONArray data, final CallbackContext callbackContext)
|
|
481
|
-
|
|
482
|
-
try
|
|
483
|
-
{
|
|
449
|
+
private boolean setColorLED(JSONArray data, final CallbackContext callbackContext) {
|
|
450
|
+
try {
|
|
484
451
|
String colorString = (String) data.get(0);
|
|
485
|
-
if (colorString == null)
|
|
452
|
+
if (colorString == null) {
|
|
486
453
|
return false;
|
|
454
|
+
}
|
|
487
455
|
|
|
488
456
|
int colorLed = GeneralUtils.parseColor(colorString);
|
|
489
457
|
PushwooshNotificationSettings.setColorLED(colorLed);
|
|
490
|
-
}
|
|
491
|
-
catch (Exception e)
|
|
492
|
-
{
|
|
458
|
+
} catch (Exception e) {
|
|
493
459
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
494
460
|
return false;
|
|
495
461
|
}
|
|
@@ -498,12 +464,11 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
498
464
|
}
|
|
499
465
|
|
|
500
466
|
@CordovaMethod
|
|
501
|
-
private boolean getPushHistory(JSONArray data, final CallbackContext callbackContext)
|
|
502
|
-
{
|
|
467
|
+
private boolean getPushHistory(JSONArray data, final CallbackContext callbackContext) {
|
|
503
468
|
List<PushMessage> pushMessageHistory = Pushwoosh.getInstance().getPushHistory();
|
|
504
469
|
List<String> pushHistory = new ArrayList<String>();
|
|
505
470
|
|
|
506
|
-
for (PushMessage pushMessage: pushMessageHistory){
|
|
471
|
+
for (PushMessage pushMessage: pushMessageHistory) {
|
|
507
472
|
pushHistory.add(pushMessage.toJson().toString());
|
|
508
473
|
}
|
|
509
474
|
callbackContext.success(new JSONArray(pushHistory));
|
|
@@ -511,29 +476,23 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
511
476
|
}
|
|
512
477
|
|
|
513
478
|
@CordovaMethod
|
|
514
|
-
private boolean clearPushHistory(JSONArray data, final CallbackContext callbackContext)
|
|
515
|
-
{
|
|
479
|
+
private boolean clearPushHistory(JSONArray data, final CallbackContext callbackContext) {
|
|
516
480
|
Pushwoosh.getInstance().clearPushHistory();
|
|
517
481
|
return true;
|
|
518
482
|
}
|
|
519
483
|
|
|
520
484
|
@CordovaMethod
|
|
521
|
-
private boolean clearNotificationCenter(JSONArray data, final CallbackContext callbackContext)
|
|
522
|
-
{
|
|
485
|
+
private boolean clearNotificationCenter(JSONArray data, final CallbackContext callbackContext) {
|
|
523
486
|
NotificationManagerCompat.from(cordova.getActivity()).cancelAll();
|
|
524
487
|
return true;
|
|
525
488
|
}
|
|
526
489
|
|
|
527
490
|
@CordovaMethod
|
|
528
|
-
private boolean setApplicationIconBadgeNumber(JSONArray data, final CallbackContext callbackContext)
|
|
529
|
-
|
|
530
|
-
try
|
|
531
|
-
{
|
|
491
|
+
private boolean setApplicationIconBadgeNumber(JSONArray data, final CallbackContext callbackContext) {
|
|
492
|
+
try {
|
|
532
493
|
Integer badgeNumber = data.getJSONObject(0).getInt("badge");
|
|
533
494
|
PushwooshBadge.setBadgeNumber(badgeNumber);
|
|
534
|
-
}
|
|
535
|
-
catch (JSONException e)
|
|
536
|
-
{
|
|
495
|
+
} catch (JSONException e) {
|
|
537
496
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
538
497
|
return false;
|
|
539
498
|
}
|
|
@@ -541,23 +500,18 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
541
500
|
}
|
|
542
501
|
|
|
543
502
|
@CordovaMethod
|
|
544
|
-
private boolean getApplicationIconBadgeNumber(JSONArray data, final CallbackContext callbackContext)
|
|
545
|
-
{
|
|
503
|
+
private boolean getApplicationIconBadgeNumber(JSONArray data, final CallbackContext callbackContext) {
|
|
546
504
|
Integer badgeNumber = PushwooshBadge.getBadgeNumber();
|
|
547
505
|
callbackContext.success(badgeNumber);
|
|
548
506
|
return true;
|
|
549
507
|
}
|
|
550
508
|
|
|
551
509
|
@CordovaMethod
|
|
552
|
-
private boolean addToApplicationIconBadgeNumber(JSONArray data, final CallbackContext callbackContext)
|
|
553
|
-
{
|
|
554
|
-
try
|
|
555
|
-
{
|
|
510
|
+
private boolean addToApplicationIconBadgeNumber(JSONArray data, final CallbackContext callbackContext) {
|
|
511
|
+
try {
|
|
556
512
|
Integer badgeNumber = data.getJSONObject(0).getInt("badge");
|
|
557
513
|
PushwooshBadge.addBadgeNumber(badgeNumber);
|
|
558
|
-
}
|
|
559
|
-
catch (JSONException e)
|
|
560
|
-
{
|
|
514
|
+
} catch (JSONException e) {
|
|
561
515
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
562
516
|
return false;
|
|
563
517
|
}
|
|
@@ -565,58 +519,46 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
565
519
|
}
|
|
566
520
|
|
|
567
521
|
@CordovaMethod
|
|
568
|
-
private boolean setUserId(JSONArray data, final CallbackContext callbackContext)
|
|
569
|
-
{
|
|
570
|
-
try
|
|
571
|
-
{
|
|
522
|
+
private boolean setUserId(JSONArray data, final CallbackContext callbackContext) {
|
|
523
|
+
try {
|
|
572
524
|
String userId = data.getString(0);
|
|
573
525
|
PushwooshInApp.getInstance().setUserId(userId);
|
|
574
|
-
}
|
|
575
|
-
catch (JSONException e)
|
|
576
|
-
{
|
|
526
|
+
} catch (JSONException e) {
|
|
577
527
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
578
528
|
}
|
|
579
529
|
return true;
|
|
580
530
|
}
|
|
581
531
|
|
|
582
532
|
@CordovaMethod
|
|
583
|
-
private boolean postEvent(JSONArray data, final CallbackContext callbackContext)
|
|
584
|
-
{
|
|
585
|
-
try
|
|
586
|
-
{
|
|
533
|
+
private boolean postEvent(JSONArray data, final CallbackContext callbackContext) {
|
|
534
|
+
try {
|
|
587
535
|
String event = data.getString(0);
|
|
588
536
|
JSONObject attributes = data.getJSONObject(1);
|
|
589
537
|
PushwooshInApp.getInstance().postEvent(event, Tags.fromJson(attributes));
|
|
590
|
-
}
|
|
591
|
-
catch (JSONException e)
|
|
592
|
-
{
|
|
538
|
+
} catch (JSONException e) {
|
|
593
539
|
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
594
540
|
}
|
|
595
541
|
return true;
|
|
596
542
|
}
|
|
597
543
|
|
|
598
544
|
@CordovaMethod
|
|
599
|
-
private boolean getRemoteNotificationStatus(JSONArray data, final CallbackContext callbackContext)
|
|
600
|
-
|
|
601
|
-
try
|
|
602
|
-
{
|
|
545
|
+
private boolean getRemoteNotificationStatus(JSONArray data, final CallbackContext callbackContext) {
|
|
546
|
+
try {
|
|
603
547
|
String enabled = PushwooshNotificationSettings.areNotificationsEnabled() ? "1" : "0";
|
|
604
548
|
JSONObject result = new JSONObject();
|
|
605
549
|
result.put("enabled", enabled);
|
|
606
550
|
callbackContext.success(result);
|
|
607
|
-
}
|
|
608
|
-
catch (Exception e)
|
|
609
|
-
{
|
|
551
|
+
} catch (Exception e) {
|
|
610
552
|
callbackContext.error(e.getMessage());
|
|
611
553
|
}
|
|
612
|
-
|
|
613
554
|
return true;
|
|
614
555
|
}
|
|
615
556
|
|
|
616
557
|
@CordovaMethod
|
|
617
558
|
private boolean presentInboxUI(JSONArray data, final CallbackContext callbackContext) {
|
|
618
|
-
if (data.length() > 0)
|
|
559
|
+
if (data.length() > 0) {
|
|
619
560
|
InboxUiStyleManager.setStyle(this.cordova.getActivity(), data.optJSONObject(0));
|
|
561
|
+
}
|
|
620
562
|
this.cordova.getActivity().startActivity(new Intent(this.cordova.getActivity(), InboxActivity.class));
|
|
621
563
|
return true;
|
|
622
564
|
}
|
|
@@ -629,17 +571,18 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
629
571
|
@Override
|
|
630
572
|
public void process(@NonNull Result<Collection<InboxMessage>, InboxMessagesException> result) {
|
|
631
573
|
CallbackContext callback = callbackIds.get("loadMessages");
|
|
632
|
-
if (callback == null)
|
|
574
|
+
if (callback == null) {
|
|
633
575
|
return;
|
|
576
|
+
}
|
|
634
577
|
|
|
635
578
|
if(result.isSuccess() && result.getData() != null) {
|
|
636
579
|
ArrayList<InboxMessage> messagesList = new ArrayList<>(result.getData());
|
|
637
580
|
JSONArray jsonArray = new JSONArray();
|
|
638
|
-
for (InboxMessage message : messagesList){
|
|
581
|
+
for (InboxMessage message : messagesList) {
|
|
639
582
|
jsonArray.put(inboxMessageToJson(message));
|
|
640
583
|
}
|
|
641
584
|
callback.success(jsonArray);
|
|
642
|
-
} else if (result.getException() != null){
|
|
585
|
+
} else if (result.getException() != null) {
|
|
643
586
|
callback.error(result.getException().getMessage());
|
|
644
587
|
}
|
|
645
588
|
}
|
|
@@ -662,12 +605,13 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
662
605
|
@Override
|
|
663
606
|
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
664
607
|
CallbackContext callback = callbackIds.get("messagesWithNoActionPerformedCount");
|
|
665
|
-
if (callback == null)
|
|
608
|
+
if (callback == null) {
|
|
666
609
|
return;
|
|
610
|
+
}
|
|
667
611
|
|
|
668
612
|
if(result.isSuccess() && result.getData() != null) {
|
|
669
613
|
callback.success(result.getData());
|
|
670
|
-
} else if (result.getException() != null){
|
|
614
|
+
} else if (result.getException() != null) {
|
|
671
615
|
callback.error(result.getException().getMessage());
|
|
672
616
|
}
|
|
673
617
|
}
|
|
@@ -690,12 +634,13 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
690
634
|
@Override
|
|
691
635
|
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
692
636
|
CallbackContext callback = callbackIds.get("unreadMessagesCount");
|
|
693
|
-
if (callback == null)
|
|
637
|
+
if (callback == null) {
|
|
694
638
|
return;
|
|
639
|
+
}
|
|
695
640
|
|
|
696
641
|
if(result.isSuccess() && result.getData() != null) {
|
|
697
642
|
callback.success(result.getData());
|
|
698
|
-
} else if (result.getException() != null){
|
|
643
|
+
} else if (result.getException() != null) {
|
|
699
644
|
callback.error(result.getException().getMessage());
|
|
700
645
|
}
|
|
701
646
|
}
|
|
@@ -718,12 +663,13 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
718
663
|
@Override
|
|
719
664
|
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
720
665
|
CallbackContext callback = callbackIds.get("messagesCount");
|
|
721
|
-
if (callback == null)
|
|
666
|
+
if (callback == null) {
|
|
722
667
|
return;
|
|
668
|
+
}
|
|
723
669
|
|
|
724
670
|
if(result.isSuccess() && result.getData() != null) {
|
|
725
671
|
callback.success(result.getData());
|
|
726
|
-
} else if (result.getException() != null){
|
|
672
|
+
} else if (result.getException() != null) {
|
|
727
673
|
callback.error(result.getException().getMessage());
|
|
728
674
|
}
|
|
729
675
|
}
|
|
@@ -772,26 +718,26 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
772
718
|
}
|
|
773
719
|
|
|
774
720
|
@CordovaMethod
|
|
775
|
-
public boolean showGDPRConsentUI(JSONArray data, final CallbackContext callbackContext){
|
|
721
|
+
public boolean showGDPRConsentUI(JSONArray data, final CallbackContext callbackContext) {
|
|
776
722
|
GDPRManager.getInstance().showGDPRConsentUI();
|
|
777
723
|
return true;
|
|
778
724
|
}
|
|
779
725
|
|
|
780
726
|
@CordovaMethod
|
|
781
|
-
public boolean showGDPRDeletionUI(JSONArray data, final CallbackContext callbackContext){
|
|
727
|
+
public boolean showGDPRDeletionUI(JSONArray data, final CallbackContext callbackContext) {
|
|
782
728
|
GDPRManager.getInstance().showGDPRDeletionUI();
|
|
783
729
|
return true;
|
|
784
730
|
}
|
|
785
731
|
|
|
786
732
|
@CordovaMethod
|
|
787
|
-
public boolean isDeviceDataRemoved(JSONArray data, final CallbackContext callbackContext){
|
|
733
|
+
public boolean isDeviceDataRemoved(JSONArray data, final CallbackContext callbackContext) {
|
|
788
734
|
boolean removed = GDPRManager.getInstance().isDeviceDataRemoved();
|
|
789
735
|
callbackContext.success(removed ? 1 : 0);
|
|
790
736
|
return true;
|
|
791
737
|
}
|
|
792
738
|
|
|
793
739
|
@CordovaMethod
|
|
794
|
-
public boolean isCommunicationEnabled(JSONArray data, final CallbackContext callbackContext){
|
|
740
|
+
public boolean isCommunicationEnabled(JSONArray data, final CallbackContext callbackContext) {
|
|
795
741
|
boolean enabled = GDPRManager.getInstance().isCommunicationEnabled();
|
|
796
742
|
callbackContext.success(enabled ? 1 : 0);
|
|
797
743
|
return true;
|
|
@@ -799,18 +745,18 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
799
745
|
}
|
|
800
746
|
|
|
801
747
|
@CordovaMethod
|
|
802
|
-
public boolean isAvailableGDPR(JSONArray data, final CallbackContext callbackContext){
|
|
748
|
+
public boolean isAvailableGDPR(JSONArray data, final CallbackContext callbackContext) {
|
|
803
749
|
boolean isAvailableGDPR = GDPRManager.getInstance().isAvailable();
|
|
804
750
|
callbackContext.success(isAvailableGDPR ? 1 : 0);
|
|
805
751
|
return true;
|
|
806
752
|
}
|
|
807
753
|
|
|
808
754
|
@CordovaMethod
|
|
809
|
-
public boolean removeAllDeviceData(JSONArray data, final CallbackContext callbackContext){
|
|
755
|
+
public boolean removeAllDeviceData(JSONArray data, final CallbackContext callbackContext) {
|
|
810
756
|
GDPRManager.getInstance().removeAllDeviceData(new Callback<Void, PushwooshException>() {
|
|
811
757
|
@Override
|
|
812
758
|
public void process(@NonNull Result<Void, PushwooshException> result) {
|
|
813
|
-
if(result.isSuccess()){
|
|
759
|
+
if(result.isSuccess()) {
|
|
814
760
|
callbackContext.success();
|
|
815
761
|
}else {
|
|
816
762
|
callbackContext.error(result.getException().getMessage());
|
|
@@ -821,13 +767,13 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
821
767
|
}
|
|
822
768
|
|
|
823
769
|
@CordovaMethod
|
|
824
|
-
public boolean setCommunicationEnabled(JSONArray data, final CallbackContext callbackContext){
|
|
770
|
+
public boolean setCommunicationEnabled(JSONArray data, final CallbackContext callbackContext) {
|
|
825
771
|
try {
|
|
826
772
|
boolean enable = data.getBoolean(0);
|
|
827
773
|
GDPRManager.getInstance().setCommunicationEnabled(enable, new Callback<Void, PushwooshException>() {
|
|
828
774
|
@Override
|
|
829
775
|
public void process(@NonNull Result<Void, PushwooshException> result) {
|
|
830
|
-
if(result.isSuccess()){
|
|
776
|
+
if(result.isSuccess()) {
|
|
831
777
|
callbackContext.success();
|
|
832
778
|
}else {
|
|
833
779
|
callbackContext.error(result.getException().getMessage());
|
|
@@ -841,89 +787,168 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
841
787
|
return false;
|
|
842
788
|
}
|
|
843
789
|
|
|
790
|
+
@CordovaMethod
|
|
791
|
+
public boolean setEmail(JSONArray data, final CallbackContext callbackContext) {
|
|
792
|
+
try {
|
|
793
|
+
String email = data.getString(0);
|
|
794
|
+
Pushwoosh.getInstance().setEmail(email, result -> {
|
|
795
|
+
if (result.isSuccess()) {
|
|
796
|
+
callbackContext.success();
|
|
797
|
+
} else {
|
|
798
|
+
callbackContext.error("Failed to set email");
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
} catch (Exception e) {
|
|
802
|
+
PWLog.error(TAG, "No parameters passed to setEmail (missing parameters)", e);
|
|
803
|
+
callbackContext.error(e.getMessage());
|
|
804
|
+
}
|
|
805
|
+
return true;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
@CordovaMethod
|
|
809
|
+
public boolean setEmails(JSONArray data, final CallbackContext callbackContext) {
|
|
810
|
+
try {
|
|
811
|
+
JSONArray emailsArray = data.getJSONArray(0);
|
|
812
|
+
List<String> emails = new ArrayList<>(emailsArray.length());
|
|
813
|
+
for (int i = 0; i < emailsArray.length(); i++) {
|
|
814
|
+
emails.add(emailsArray.getString(i));
|
|
815
|
+
}
|
|
816
|
+
Pushwoosh.getInstance().setEmail(emails, result -> {
|
|
817
|
+
if (result.isSuccess()) {
|
|
818
|
+
callbackContext.success();
|
|
819
|
+
} else {
|
|
820
|
+
callbackContext.error("Failed to set emails");
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
} catch (Exception e) {
|
|
824
|
+
PWLog.error(TAG, "No parameters passed to setEmails (missing parameters)", e);
|
|
825
|
+
callbackContext.error(e.getMessage());
|
|
826
|
+
}
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
@CordovaMethod
|
|
831
|
+
public boolean setUserEmails(JSONArray data, final CallbackContext callbackContext) {
|
|
832
|
+
try {
|
|
833
|
+
String userId = data.getString(0);
|
|
834
|
+
JSONArray emailsArray = data.getJSONArray(1);
|
|
835
|
+
List<String> emails = new ArrayList<>(emailsArray.length());
|
|
836
|
+
for (int i = 0; i < emailsArray.length(); i++) {
|
|
837
|
+
emails.add(emailsArray.getString(i));
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
Pushwoosh.getInstance().setUser(userId, emails, result -> {
|
|
841
|
+
if (result.isSuccess()) {
|
|
842
|
+
callbackContext.success();
|
|
843
|
+
} else {
|
|
844
|
+
callbackContext.error("Failed to set user emails");
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
} catch (Exception e) {
|
|
848
|
+
PWLog.error(TAG, "No parameters passed to setUserEmails (missing parameters)", e);
|
|
849
|
+
callbackContext.error(e.getMessage());
|
|
850
|
+
}
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
@CordovaMethod
|
|
855
|
+
private boolean registerSMSNumber(JSONArray data, final CallbackContext callbackContext) {
|
|
856
|
+
try {
|
|
857
|
+
String phoneNumber = data.getString(0);
|
|
858
|
+
Pushwoosh.getInstance().registerSMSNumber(phoneNumber);
|
|
859
|
+
} catch (Exception e) {
|
|
860
|
+
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
861
|
+
callbackContext.error(e.getMessage());
|
|
862
|
+
}
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
@CordovaMethod
|
|
867
|
+
private boolean registerWhatsappNumber(JSONArray data, final CallbackContext callbackContext) {
|
|
868
|
+
try {
|
|
869
|
+
String phoneNumber = data.getString(0);
|
|
870
|
+
Pushwoosh.getInstance().registerWhatsappNumber(phoneNumber);
|
|
871
|
+
} catch (Exception e) {
|
|
872
|
+
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
873
|
+
callbackContext.error(e.getMessage());
|
|
874
|
+
}
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
|
|
844
878
|
@CordovaMethod
|
|
845
879
|
public boolean enableHuaweiPushNotifications(JSONArray data, final CallbackContext callbackContext) {
|
|
846
880
|
Pushwoosh.getInstance().enableHuaweiPushNotifications();
|
|
847
881
|
return true;
|
|
848
882
|
}
|
|
849
883
|
|
|
850
|
-
|
|
851
884
|
@Override
|
|
852
|
-
public boolean execute(String action, JSONArray data, CallbackContext callbackId)
|
|
853
|
-
{
|
|
885
|
+
public boolean execute(String action, JSONArray data, CallbackContext callbackId) {
|
|
854
886
|
PWLog.debug(TAG, "Plugin Method Called: " + action);
|
|
855
887
|
|
|
856
888
|
Method method = exportedMethods.get(action);
|
|
857
|
-
if (method == null)
|
|
858
|
-
{
|
|
889
|
+
if (method == null) {
|
|
859
890
|
PWLog.debug(TAG, "Invalid action : " + action + " passed");
|
|
860
891
|
return false;
|
|
861
892
|
}
|
|
862
893
|
|
|
863
|
-
try
|
|
864
|
-
{
|
|
894
|
+
try {
|
|
865
895
|
Boolean result = (Boolean) method.invoke(this, data, callbackId);
|
|
866
896
|
return result;
|
|
867
897
|
}
|
|
868
|
-
catch (Exception e)
|
|
869
|
-
{
|
|
898
|
+
catch (Exception e) {
|
|
870
899
|
PWLog.error(TAG, "Failed to execute action : " + action, e);
|
|
871
900
|
return false;
|
|
872
901
|
}
|
|
873
902
|
}
|
|
874
903
|
|
|
875
|
-
private void doOnRegistered(String registrationId)
|
|
876
|
-
{
|
|
904
|
+
private void doOnRegistered(String registrationId) {
|
|
877
905
|
CallbackContext callback = callbackIds.get("registerDevice");
|
|
878
|
-
if (callback == null)
|
|
906
|
+
if (callback == null) {
|
|
879
907
|
return;
|
|
908
|
+
}
|
|
880
909
|
|
|
881
|
-
try
|
|
882
|
-
{
|
|
910
|
+
try {
|
|
883
911
|
JSONObject result = new JSONObject();
|
|
884
912
|
result.put("pushToken", registrationId);
|
|
885
913
|
callback.success(result);
|
|
886
|
-
}
|
|
887
|
-
catch (Exception e)
|
|
888
|
-
{
|
|
914
|
+
} catch (Exception e) {
|
|
889
915
|
callback.error("Internal error");
|
|
890
916
|
}
|
|
891
917
|
|
|
892
918
|
callbackIds.remove("registerDevice");
|
|
893
919
|
}
|
|
894
920
|
|
|
895
|
-
private void doOnRegisteredError(String errorId)
|
|
896
|
-
{
|
|
921
|
+
private void doOnRegisteredError(String errorId) {
|
|
897
922
|
CallbackContext callback = callbackIds.get("registerDevice");
|
|
898
|
-
if (callback == null)
|
|
923
|
+
if (callback == null) {
|
|
899
924
|
return;
|
|
925
|
+
}
|
|
900
926
|
|
|
901
927
|
callback.error(errorId);
|
|
902
928
|
callbackIds.remove("registerDevice");
|
|
903
929
|
}
|
|
904
930
|
|
|
905
|
-
private void doOnUnregistered(String registrationId)
|
|
906
|
-
{
|
|
931
|
+
private void doOnUnregistered(String registrationId) {
|
|
907
932
|
CallbackContext callback = callbackIds.get("unregisterDevice");
|
|
908
|
-
if (callback == null)
|
|
933
|
+
if (callback == null) {
|
|
909
934
|
return;
|
|
935
|
+
}
|
|
910
936
|
|
|
911
937
|
callback.success(registrationId);
|
|
912
938
|
callbackIds.remove("unregisterDevice");
|
|
913
939
|
}
|
|
914
940
|
|
|
915
|
-
private void doOnUnregisteredError(String errorId)
|
|
916
|
-
{
|
|
941
|
+
private void doOnUnregisteredError(String errorId) {
|
|
917
942
|
CallbackContext callback = callbackIds.get("unregisterDevice");
|
|
918
|
-
if (callback == null)
|
|
943
|
+
if (callback == null) {
|
|
919
944
|
return;
|
|
945
|
+
}
|
|
920
946
|
|
|
921
947
|
callback.error(errorId);
|
|
922
948
|
callbackIds.remove("unregisterDevice");
|
|
923
949
|
}
|
|
924
950
|
|
|
925
|
-
private void doOnPushOpened(String notification)
|
|
926
|
-
{
|
|
951
|
+
private void doOnPushOpened(String notification) {
|
|
927
952
|
PWLog.debug(TAG, "push opened: " + notification);
|
|
928
953
|
|
|
929
954
|
String jsStatement = String.format("cordova.require(\"pushwoosh-cordova-plugin.PushNotification\").notificationCallback(%s);", convertNotification(notification));
|
|
@@ -931,8 +956,7 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
931
956
|
sStartPushData = null;
|
|
932
957
|
}
|
|
933
958
|
|
|
934
|
-
public void doOnPushReceived(String notification)
|
|
935
|
-
{
|
|
959
|
+
public void doOnPushReceived(String notification) {
|
|
936
960
|
PWLog.debug(TAG, "push received: " + notification);
|
|
937
961
|
|
|
938
962
|
String jsStatement = String.format("cordova.require(\"pushwoosh-cordova-plugin.PushNotification\").pushReceivedCallback(%s);", convertNotification(notification));
|
|
@@ -941,12 +965,10 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
941
965
|
sReceivedPushData = null;
|
|
942
966
|
}
|
|
943
967
|
|
|
944
|
-
private String convertNotification(String notification)
|
|
945
|
-
{
|
|
968
|
+
private String convertNotification(String notification) {
|
|
946
969
|
JSONObject unifiedNotification = new JSONObject();
|
|
947
970
|
|
|
948
|
-
try
|
|
949
|
-
{
|
|
971
|
+
try {
|
|
950
972
|
JSONObject notificationJson = new JSONObject(notification);
|
|
951
973
|
String pushMessage = notificationJson.optString("title");
|
|
952
974
|
Boolean foreground = notificationJson.optBoolean("foreground");
|
|
@@ -959,8 +981,7 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
959
981
|
unifiedNotification.put("foreground", foreground);
|
|
960
982
|
unifiedNotification.put("onStart", onStart);
|
|
961
983
|
unifiedNotification.put("userdata", userData);
|
|
962
|
-
}
|
|
963
|
-
catch (JSONException e) {
|
|
984
|
+
} catch (JSONException e) {
|
|
964
985
|
PWLog.error(TAG, "push message parsing failed", e);
|
|
965
986
|
}
|
|
966
987
|
|
|
@@ -972,21 +993,15 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
972
993
|
return result;
|
|
973
994
|
}
|
|
974
995
|
|
|
975
|
-
private void evalJs(String statement)
|
|
976
|
-
{
|
|
996
|
+
private void evalJs(String statement) {
|
|
977
997
|
final String url = "javascript:" + statement;
|
|
978
998
|
|
|
979
|
-
handler.post(new Runnable()
|
|
980
|
-
{
|
|
999
|
+
handler.post(new Runnable() {
|
|
981
1000
|
@Override
|
|
982
|
-
public void run()
|
|
983
|
-
|
|
984
|
-
try
|
|
985
|
-
{
|
|
1001
|
+
public void run() {
|
|
1002
|
+
try {
|
|
986
1003
|
webView.loadUrl(url);
|
|
987
|
-
}
|
|
988
|
-
catch (Exception e)
|
|
989
|
-
{
|
|
1004
|
+
} catch (Exception e) {
|
|
990
1005
|
PWLog.exception(e);
|
|
991
1006
|
}
|
|
992
1007
|
}
|
|
@@ -674,6 +674,64 @@ API_AVAILABLE(ios(10.0)) {
|
|
|
674
674
|
}];
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
+
- (void)setEmail:(CDVInvokedUrlCommand *)command {
|
|
678
|
+
NSString *email = command.arguments[0];
|
|
679
|
+
[[Pushwoosh sharedInstance] setEmail:email completion:^(NSError *error) {
|
|
680
|
+
CDVPluginResult *pluginResult;
|
|
681
|
+
if (!error) {
|
|
682
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
683
|
+
} else {
|
|
684
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to set email"];
|
|
685
|
+
}
|
|
686
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
687
|
+
}];
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
- (void)setEmails:(CDVInvokedUrlCommand *)command {
|
|
691
|
+
NSArray *emailsArray = command.arguments[0];
|
|
692
|
+
for (NSString *email in emailsArray) {
|
|
693
|
+
[[Pushwoosh sharedInstance] setEmail:email completion:^(NSError *error) {
|
|
694
|
+
CDVPluginResult *pluginResult;
|
|
695
|
+
if (!error) {
|
|
696
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
697
|
+
} else {
|
|
698
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to set emails"];
|
|
699
|
+
}
|
|
700
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
701
|
+
}];
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
- (void)setUserEmails:(CDVInvokedUrlCommand *)command {
|
|
706
|
+
NSString *userId = command.arguments[0];
|
|
707
|
+
NSArray *emailsArray = command.arguments[1];
|
|
708
|
+
for (NSString *email in emailsArray) {
|
|
709
|
+
[[Pushwoosh sharedInstance] setUser:userId emails:@[email] completion:^(NSError *error) {
|
|
710
|
+
CDVPluginResult *pluginResult;
|
|
711
|
+
if (!error) {
|
|
712
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
713
|
+
} else {
|
|
714
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to set user emails"];
|
|
715
|
+
}
|
|
716
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
717
|
+
}];
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
- (void)registerSMSNumber:(CDVInvokedUrlCommand *)command {
|
|
722
|
+
NSString *phoneNumber = command.arguments[0];
|
|
723
|
+
[[Pushwoosh sharedInstance] registerSmsNumber:phoneNumber];
|
|
724
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
725
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
- (void)registerWhatsappNumber:(CDVInvokedUrlCommand *)command {
|
|
729
|
+
NSString *phoneNumber = command.arguments[0];
|
|
730
|
+
[[Pushwoosh sharedInstance] registerWhatsappNumber:phoneNumber];
|
|
731
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
732
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
733
|
+
}
|
|
734
|
+
|
|
677
735
|
- (void)removeAllDeviceData:(CDVInvokedUrlCommand *)command {
|
|
678
736
|
self.callbackIds[@"removeAllDeviceData"] = command.callbackId;
|
|
679
737
|
|
|
@@ -87,4 +87,9 @@ export interface PushNotification {
|
|
|
87
87
|
setColorLED(color: string, success?: () => void, fail?: () => void): void;
|
|
88
88
|
getPushHistory(success?: (pushHistory: Object) => void): void;
|
|
89
89
|
clearPushHistory(callback: () => void): void;
|
|
90
|
+
setEmail(email: string, success?: () => void, fail?: (error: Error|string) => void): void;
|
|
91
|
+
setEmails(emails: string[], success?: () => void, fail?: (error: Error|string) => void): void;
|
|
92
|
+
setUserEmails(userId: string, emails: string[], success?: () => void, fail?: (error: Error|string) => void): void;
|
|
93
|
+
registerSMSNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
|
|
94
|
+
registerWhatsappNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
|
|
90
95
|
}
|
package/www/PushNotification.js
CHANGED
|
@@ -614,6 +614,36 @@ PushNotification.prototype.setCommunicationEnabled = function(enable, success, f
|
|
|
614
614
|
exec(success, fail, "PushNotification", "setCommunicationEnabled", [enable]);
|
|
615
615
|
};
|
|
616
616
|
|
|
617
|
+
// Register email associated to the current user.
|
|
618
|
+
// Email should be a string and could not be null or empty.
|
|
619
|
+
PushNotification.prototype.setEmail = function(email, success, fail) {
|
|
620
|
+
exec(success, fail, "PushNotification", "setEmail", [email]);
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
// Register list of emails associated to the current user.
|
|
624
|
+
PushNotification.prototype.setEmails = function(emails, success, fail) {
|
|
625
|
+
exec(success, fail, "PushNotification", "setEmails", [emails]);
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
// Set user identifier and register emails associated to the user.
|
|
629
|
+
// userID can be Facebook ID or any other user ID.
|
|
630
|
+
// This allows data and events to be matched across multiple user devices.
|
|
631
|
+
PushNotification.prototype.setUserEmails = function(userId, emails, success, fail) {
|
|
632
|
+
exec(success, fail, "PushNotification", "setUserEmails", [userId, emails]);
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
// Registers phone number associated to the current user.
|
|
636
|
+
// PhoneNumber should be a string and cannot be null or empty.
|
|
637
|
+
PushNotification.prototype.registerSMSNumber = function(phoneNumber, success, fail) {
|
|
638
|
+
exec(success, fail, "PushNotification", "registerSMSNumber", [phoneNumber]);
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// Registers Whatsapp number associated to the current user.
|
|
642
|
+
// PhoneNumber should be a string and cannot be null or empty.
|
|
643
|
+
PushNotification.prototype.registerWhatsappNumber = function(phoneNumber, success, fail) {
|
|
644
|
+
exec(success, fail, "PushNotification", "registerWhatsappNumber", [phoneNumber]);
|
|
645
|
+
};
|
|
646
|
+
|
|
617
647
|
// Removes all device data from Pushwoosh and stops all interactions and communication permanently.
|
|
618
648
|
PushNotification.prototype.removeAllDeviceData = function(success, fail) {
|
|
619
649
|
exec(success, fail, "PushNotification", "removeAllDeviceData", []);
|