pushwoosh-cordova-plugin 8.3.15 → 8.3.17
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 +3 -3
- package/README_PGB.md +1 -1
- package/build-extras-pushwoosh.gradle +2 -1
- package/package.json +1 -1
- package/plugin.xml +10 -10
- package/src/android/src/com/pushwoosh/plugin/pushnotifications/PushNotifications.java +197 -3
- package/src/ios/PushNotification.m +112 -0
- package/types/PushNotification.d.ts +22 -0
- package/www/PushNotification.js +46 -0
package/README.md
CHANGED
|
@@ -14,13 +14,13 @@ Cross-Platform push notifications by Pushwoosh for Cordova / PhoneGap
|
|
|
14
14
|
Using npm (requires cordova 7.0+):
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
cordova plugin add pushwoosh-cordova-plugin@8.3.
|
|
17
|
+
cordova plugin add pushwoosh-cordova-plugin@8.3.17
|
|
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.17
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
#### Phonegap
|
|
@@ -28,7 +28,7 @@ cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-plugin.git#8.
|
|
|
28
28
|
Using npm (requires phonegap 7.1+):
|
|
29
29
|
|
|
30
30
|
```
|
|
31
|
-
cordova plugin add pushwoosh-cordova-plugin@8.3.
|
|
31
|
+
cordova plugin add pushwoosh-cordova-plugin@8.3.17
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### Guide
|
package/README_PGB.md
CHANGED
|
@@ -4,5 +4,6 @@ repositories {
|
|
|
4
4
|
|
|
5
5
|
dependencies {
|
|
6
6
|
implementation 'com.google.firebase:firebase-core:(+,21.0.99]'
|
|
7
|
-
implementation 'com.google.firebase:firebase-messaging:(+,23.
|
|
7
|
+
implementation 'com.google.firebase:firebase-messaging:(+,23.1.99]'
|
|
8
|
+
implementation 'androidx.databinding:viewbinding:8.1.1'
|
|
8
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pushwoosh-cordova-plugin",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.17",
|
|
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.17">
|
|
3
3
|
|
|
4
4
|
<name>Pushwoosh</name>
|
|
5
5
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<platform name="android">
|
|
29
29
|
<config-file target="config.xml" parent="/*">
|
|
30
30
|
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
|
|
31
|
-
<preference name="GradlePluginGoogleServicesVersion" value="4.3.
|
|
31
|
+
<preference name="GradlePluginGoogleServicesVersion" value="4.3.15" />
|
|
32
32
|
</config-file>
|
|
33
33
|
|
|
34
34
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
|
@@ -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.
|
|
81
|
-
<framework src="com.pushwoosh:pushwoosh-amazon:6.
|
|
82
|
-
<framework src="com.pushwoosh:pushwoosh-firebase:6.
|
|
83
|
-
<framework src="com.pushwoosh:pushwoosh-badge:6.
|
|
84
|
-
<framework src="com.pushwoosh:pushwoosh-inbox:6.
|
|
85
|
-
<framework src="com.pushwoosh:pushwoosh-inbox-ui:6.
|
|
86
|
-
<framework src="com.pushwoosh:pushwoosh-huawei:6.
|
|
80
|
+
<framework src="com.pushwoosh:pushwoosh:6.7.0"/>
|
|
81
|
+
<framework src="com.pushwoosh:pushwoosh-amazon:6.7.0"/>
|
|
82
|
+
<framework src="com.pushwoosh:pushwoosh-firebase:6.7.0"/>
|
|
83
|
+
<framework src="com.pushwoosh:pushwoosh-badge:6.7.0"/>
|
|
84
|
+
<framework src="com.pushwoosh:pushwoosh-inbox:6.7.0"/>
|
|
85
|
+
<framework src="com.pushwoosh:pushwoosh-inbox-ui:6.7.0"/>
|
|
86
|
+
<framework src="com.pushwoosh:pushwoosh-huawei:6.7.0"/>
|
|
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.
|
|
128
|
+
<pod name="PushwooshXCFramework" spec="6.5.1" />
|
|
129
129
|
<pod name="PushwooshInboxUIXCFramework" spec="6.1.1" />
|
|
130
130
|
</pods>
|
|
131
131
|
</podspec>
|
|
@@ -29,8 +29,12 @@ import com.pushwoosh.exception.UnregisterForPushNotificationException;
|
|
|
29
29
|
import com.pushwoosh.function.Callback;
|
|
30
30
|
import com.pushwoosh.function.Result;
|
|
31
31
|
import com.pushwoosh.inapp.PushwooshInApp;
|
|
32
|
+
import com.pushwoosh.inbox.PushwooshInbox;
|
|
33
|
+
import com.pushwoosh.inbox.data.InboxMessage;
|
|
34
|
+
import com.pushwoosh.inbox.exception.InboxMessagesException;
|
|
32
35
|
import com.pushwoosh.inbox.ui.presentation.view.activity.InboxActivity;
|
|
33
36
|
import com.pushwoosh.internal.platform.utils.GeneralUtils;
|
|
37
|
+
import com.pushwoosh.internal.utils.JsonUtils;
|
|
34
38
|
import com.pushwoosh.internal.utils.PWLog;
|
|
35
39
|
import com.pushwoosh.notification.LocalNotification;
|
|
36
40
|
import com.pushwoosh.notification.LocalNotificationReceiver;
|
|
@@ -43,7 +47,6 @@ import com.pushwoosh.tags.TagsBundle;
|
|
|
43
47
|
|
|
44
48
|
import org.apache.cordova.CallbackContext;
|
|
45
49
|
import org.apache.cordova.CordovaPlugin;
|
|
46
|
-
import org.apache.cordova.CordovaWebView;
|
|
47
50
|
import org.json.JSONArray;
|
|
48
51
|
import org.json.JSONException;
|
|
49
52
|
import org.json.JSONObject;
|
|
@@ -52,6 +55,7 @@ import java.lang.annotation.Retention;
|
|
|
52
55
|
import java.lang.reflect.Method;
|
|
53
56
|
import java.util.ArrayList;
|
|
54
57
|
import java.util.Arrays;
|
|
58
|
+
import java.util.Collection;
|
|
55
59
|
import java.util.HashMap;
|
|
56
60
|
import java.util.List;
|
|
57
61
|
import java.util.Map;
|
|
@@ -219,6 +223,21 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
219
223
|
return true;
|
|
220
224
|
}
|
|
221
225
|
|
|
226
|
+
@CordovaMethod
|
|
227
|
+
private boolean setLanguage(JSONArray data, final CallbackContext callbackContext)
|
|
228
|
+
{
|
|
229
|
+
try
|
|
230
|
+
{
|
|
231
|
+
String language = data.getString(0);
|
|
232
|
+
Pushwoosh.getInstance().setLanguage(language);
|
|
233
|
+
}
|
|
234
|
+
catch (JSONException e)
|
|
235
|
+
{
|
|
236
|
+
PWLog.error(TAG, "No parameters passed (missing parameters)", e);
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
|
|
222
241
|
@CordovaMethod
|
|
223
242
|
private boolean setTags(JSONArray data, final CallbackContext callbackContext) {
|
|
224
243
|
JSONObject params;
|
|
@@ -307,12 +326,12 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
307
326
|
if (message == null) {
|
|
308
327
|
return false;
|
|
309
328
|
}
|
|
310
|
-
|
|
329
|
+
|
|
311
330
|
Bundle extras = new Bundle();
|
|
312
331
|
if (params.has("userData")) {
|
|
313
332
|
extras.putString("u", params.getString("userData"));
|
|
314
333
|
}
|
|
315
|
-
|
|
334
|
+
|
|
316
335
|
LocalNotification notification = new LocalNotification.Builder()
|
|
317
336
|
.setMessage(message)
|
|
318
337
|
.setDelay(seconds)
|
|
@@ -588,6 +607,156 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
588
607
|
return true;
|
|
589
608
|
}
|
|
590
609
|
|
|
610
|
+
@CordovaMethod
|
|
611
|
+
private boolean loadMessages(JSONArray data, final CallbackContext callbackContext) {
|
|
612
|
+
try {
|
|
613
|
+
callbackIds.put("loadMessages", callbackContext);
|
|
614
|
+
PushwooshInbox.loadMessages(new Callback<Collection<InboxMessage>, InboxMessagesException>() {
|
|
615
|
+
@Override
|
|
616
|
+
public void process(@NonNull Result<Collection<InboxMessage>, InboxMessagesException> result) {
|
|
617
|
+
CallbackContext callback = callbackIds.get("loadMessages");
|
|
618
|
+
if (callback == null)
|
|
619
|
+
return;
|
|
620
|
+
|
|
621
|
+
if(result.isSuccess() && result.getData() != null) {
|
|
622
|
+
ArrayList<InboxMessage> messagesList = new ArrayList<>(result.getData());
|
|
623
|
+
JSONArray jsonArray = new JSONArray();
|
|
624
|
+
for (InboxMessage message : messagesList){
|
|
625
|
+
jsonArray.put(inboxMessageToJson(message));
|
|
626
|
+
}
|
|
627
|
+
callback.success(jsonArray);
|
|
628
|
+
} else if (result.getException() != null){
|
|
629
|
+
callback.error(result.getException().getMessage());
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
} catch (java.lang.RuntimeException e) {
|
|
634
|
+
callbackIds.remove("loadMessages");
|
|
635
|
+
PWLog.error(TAG, "Failed to load inbox messages", e);
|
|
636
|
+
|
|
637
|
+
callbackContext.error(e.getMessage());
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
@CordovaMethod
|
|
644
|
+
public boolean messagesWithNoActionPerformedCount(JSONArray data, final CallbackContext callbackContext) {
|
|
645
|
+
try {
|
|
646
|
+
callbackIds.put("messagesWithNoActionPerformedCount", callbackContext);
|
|
647
|
+
PushwooshInbox.messagesWithNoActionPerformedCount(new Callback<Integer, InboxMessagesException>() {
|
|
648
|
+
@Override
|
|
649
|
+
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
650
|
+
CallbackContext callback = callbackIds.get("messagesWithNoActionPerformedCount");
|
|
651
|
+
if (callback == null)
|
|
652
|
+
return;
|
|
653
|
+
|
|
654
|
+
if(result.isSuccess() && result.getData() != null) {
|
|
655
|
+
callback.success(result.getData());
|
|
656
|
+
} else if (result.getException() != null){
|
|
657
|
+
callback.error(result.getException().getMessage());
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
} catch (java.lang.RuntimeException e) {
|
|
662
|
+
callbackIds.remove("messagesWithNoActionPerformedCount");
|
|
663
|
+
PWLog.error(TAG, "Failed to get number of messages with no action", e);
|
|
664
|
+
|
|
665
|
+
callbackContext.error(e.getMessage());
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return true;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
@CordovaMethod
|
|
672
|
+
public boolean unreadMessagesCount(JSONArray data, final CallbackContext callbackContext) {
|
|
673
|
+
try {
|
|
674
|
+
callbackIds.put("unreadMessagesCount", callbackContext);
|
|
675
|
+
PushwooshInbox.unreadMessagesCount(new Callback<Integer, InboxMessagesException>() {
|
|
676
|
+
@Override
|
|
677
|
+
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
678
|
+
CallbackContext callback = callbackIds.get("unreadMessagesCount");
|
|
679
|
+
if (callback == null)
|
|
680
|
+
return;
|
|
681
|
+
|
|
682
|
+
if(result.isSuccess() && result.getData() != null) {
|
|
683
|
+
callback.success(result.getData());
|
|
684
|
+
} else if (result.getException() != null){
|
|
685
|
+
callback.error(result.getException().getMessage());
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
} catch (java.lang.RuntimeException e) {
|
|
690
|
+
callbackIds.remove(" unreadMessagesCount");
|
|
691
|
+
PWLog.error(TAG, "Failed to get number of unread messages", e);
|
|
692
|
+
|
|
693
|
+
callbackContext.error(e.getMessage());
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
@CordovaMethod
|
|
700
|
+
public boolean messagesCount(JSONArray data, final CallbackContext callbackContext) {
|
|
701
|
+
try {
|
|
702
|
+
callbackIds.put("messagesCount", callbackContext);
|
|
703
|
+
PushwooshInbox.messagesCount(new Callback<Integer, InboxMessagesException>() {
|
|
704
|
+
@Override
|
|
705
|
+
public void process(@NonNull Result<Integer, InboxMessagesException> result) {
|
|
706
|
+
CallbackContext callback = callbackIds.get("messagesCount");
|
|
707
|
+
if (callback == null)
|
|
708
|
+
return;
|
|
709
|
+
|
|
710
|
+
if(result.isSuccess() && result.getData() != null) {
|
|
711
|
+
callback.success(result.getData());
|
|
712
|
+
} else if (result.getException() != null){
|
|
713
|
+
callback.error(result.getException().getMessage());
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
} catch (java.lang.RuntimeException e) {
|
|
718
|
+
callbackIds.remove(" messagesCount");
|
|
719
|
+
PWLog.error(TAG, "Failed to get total number of inbox messages", e);
|
|
720
|
+
|
|
721
|
+
callbackContext.error(e.getMessage());
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
@CordovaMethod
|
|
728
|
+
public boolean readMessage(JSONArray data, final CallbackContext callbackContext) {
|
|
729
|
+
try {
|
|
730
|
+
PushwooshInbox.readMessage(data.getString(0));
|
|
731
|
+
return true;
|
|
732
|
+
} catch (JSONException e) {
|
|
733
|
+
PWLog.error(TAG, "Failed to mark inbox message as read", e);
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
@CordovaMethod
|
|
739
|
+
public boolean deleteMessage(JSONArray data, final CallbackContext callbackContext) {
|
|
740
|
+
try {
|
|
741
|
+
PushwooshInbox.deleteMessage(data.getString(0));
|
|
742
|
+
return true;
|
|
743
|
+
} catch (JSONException e) {
|
|
744
|
+
PWLog.error(TAG, "Failed to delete inbox message", e);
|
|
745
|
+
return false;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
@CordovaMethod
|
|
750
|
+
public boolean performAction(JSONArray data, final CallbackContext callbackContext) {
|
|
751
|
+
try {
|
|
752
|
+
PushwooshInbox.performAction(data.getString(0));
|
|
753
|
+
return true;
|
|
754
|
+
} catch (JSONException e) {
|
|
755
|
+
PWLog.error(TAG, "Failed to perform action for inbox message", e);
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
591
760
|
@CordovaMethod
|
|
592
761
|
public boolean showGDPRConsentUI(JSONArray data, final CallbackContext callbackContext){
|
|
593
762
|
GDPRManager.getInstance().showGDPRConsentUI();
|
|
@@ -872,4 +1041,29 @@ public class PushNotifications extends CordovaPlugin {
|
|
|
872
1041
|
return true;
|
|
873
1042
|
}
|
|
874
1043
|
|
|
1044
|
+
private static JSONObject inboxMessageToJson(InboxMessage message) {
|
|
1045
|
+
JSONObject object = new JSONObject();
|
|
1046
|
+
try {
|
|
1047
|
+
object.put("code", message.getCode())
|
|
1048
|
+
.put("title", message.getTitle())
|
|
1049
|
+
.put("imageUrl", message.getImageUrl())
|
|
1050
|
+
.put("message",message.getMessage())
|
|
1051
|
+
.put("sendDate",message.getISO8601SendDate())
|
|
1052
|
+
.put("type", message.getType().getCode())
|
|
1053
|
+
.put("bannerUrl", message.getBannerUrl())
|
|
1054
|
+
.put("isRead",message.isRead())
|
|
1055
|
+
.put("actionParams",message.getActionParams())
|
|
1056
|
+
.put("isActionPerformed",message.isActionPerformed());
|
|
1057
|
+
|
|
1058
|
+
Bundle bundle = JsonUtils.jsonStringToBundle( message.getActionParams());
|
|
1059
|
+
String customData = bundle.getString("u");
|
|
1060
|
+
if (customData != null) {
|
|
1061
|
+
object.put("customData", customData);
|
|
1062
|
+
}
|
|
1063
|
+
} catch (JSONException e) {
|
|
1064
|
+
PWLog.error("PushwooshInbox", "Failed to fetch inbox message :" + e.getMessage());
|
|
1065
|
+
}
|
|
1066
|
+
return object;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
875
1069
|
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#import <PushwooshInboxUI/PushwooshInboxUI.h>
|
|
16
16
|
#import <Pushwoosh/PWGDPRManager.h>
|
|
17
17
|
#import <Pushwoosh/PWInAppManager.h>
|
|
18
|
+
#import <Pushwoosh/PWInbox.h>
|
|
18
19
|
#import "PWBackward.h"
|
|
19
20
|
|
|
20
21
|
#import "AppDelegate.h"
|
|
@@ -230,6 +231,11 @@ static PushNotification *pw_PushNotificationPlugin;
|
|
|
230
231
|
}];
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
- (void)setLanguage:(CDVInvokedUrlCommand *)command {
|
|
235
|
+
NSString *language = command.arguments[0];
|
|
236
|
+
[[Pushwoosh sharedInstance] setLanguage:language];
|
|
237
|
+
}
|
|
238
|
+
|
|
233
239
|
- (void)startBeaconPushes:(CDVInvokedUrlCommand *)command {
|
|
234
240
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{ @"error" : @"Beacon tracking is not supported" }];
|
|
235
241
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
@@ -269,6 +275,83 @@ static PushNotification *pw_PushNotificationPlugin;
|
|
|
269
275
|
}];
|
|
270
276
|
}
|
|
271
277
|
|
|
278
|
+
- (void)loadMessages:(CDVInvokedUrlCommand *)command {
|
|
279
|
+
// The first argument in the arguments parameter is the callbackID.
|
|
280
|
+
self.callbackIds[@"loadMessages"] = command.callbackId;
|
|
281
|
+
[PWInbox loadMessagesWithCompletion:^(NSArray<NSObject<PWInboxMessageProtocol> *> *messages, NSError *error) {
|
|
282
|
+
if (!error) {
|
|
283
|
+
NSMutableArray* array = [[NSMutableArray alloc] init];
|
|
284
|
+
for (NSObject<PWInboxMessageProtocol>* message in messages) {
|
|
285
|
+
NSDictionary* dict = [self inboxMessageToDictionary:message];
|
|
286
|
+
[array addObject:dict];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:array];
|
|
290
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"loadMessages"]];
|
|
291
|
+
} else {
|
|
292
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.localizedDescription];
|
|
293
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"loadMessages"]];
|
|
294
|
+
}
|
|
295
|
+
}];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
- (void)unreadMessagesCount:(CDVInvokedUrlCommand *)command {
|
|
299
|
+
// The first argument in the arguments parameter is the callbackID.
|
|
300
|
+
self.callbackIds[@"unreadMessagesCount"] = command.callbackId;
|
|
301
|
+
[PWInbox unreadMessagesCountWithCompletion:^(NSInteger count, NSError *error) {
|
|
302
|
+
if (!error) {
|
|
303
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)count];
|
|
304
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"unreadMessagesCount"]];
|
|
305
|
+
}
|
|
306
|
+
}];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
- (void)messagesWithNoActionPerformedCount:(CDVInvokedUrlCommand *)command {
|
|
310
|
+
// The first argument in the arguments parameter is the callbackID.
|
|
311
|
+
self.callbackIds[@"messagesWithNoActionPerformedCount"] = command.callbackId;
|
|
312
|
+
[PWInbox messagesWithNoActionPerformedCountWithCompletion:^(NSInteger count, NSError *error) {
|
|
313
|
+
if (!error) {
|
|
314
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)count];
|
|
315
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"messagesWithNoActionPerformedCount"]];
|
|
316
|
+
}
|
|
317
|
+
}];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
- (void)messagesCount:(CDVInvokedUrlCommand *)command {
|
|
321
|
+
// The first argument in the arguments parameter is the callbackID.
|
|
322
|
+
self.callbackIds[@"messagesCount"] = command.callbackId;
|
|
323
|
+
[PWInbox messagesCountWithCompletion:^(NSInteger count, NSError *error) {
|
|
324
|
+
if (!error) {
|
|
325
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)count];
|
|
326
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"messagesCount"]];
|
|
327
|
+
}
|
|
328
|
+
}];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
- (void)readMessage:(CDVInvokedUrlCommand *)command {
|
|
332
|
+
NSString *messageCode = command.arguments[0];
|
|
333
|
+
if (messageCode.length != 0) {
|
|
334
|
+
NSArray *array = [NSArray arrayWithObject:messageCode];
|
|
335
|
+
[PWInbox readMessagesWithCodes:array];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
- (void)deleteMessage:(CDVInvokedUrlCommand *)command {
|
|
340
|
+
NSString *messageCode = command.arguments[0];
|
|
341
|
+
if (messageCode.length != 0) {
|
|
342
|
+
NSArray *array = [NSArray arrayWithObject:messageCode];
|
|
343
|
+
[PWInbox deleteMessagesWithCodes:array];
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
- (void)performAction:(CDVInvokedUrlCommand *)command {
|
|
348
|
+
NSString *messageCode = command.arguments[0];
|
|
349
|
+
if (messageCode.length != 0) {
|
|
350
|
+
[PWInbox performActionForMessageWithCode:messageCode];
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
|
|
272
355
|
- (void)createLocalNotification:(CDVInvokedUrlCommand *)command {
|
|
273
356
|
NSDictionary *params = command.arguments[0];
|
|
274
357
|
NSString *body = params[@"msg"];
|
|
@@ -656,6 +739,35 @@ BOOL pwplugin_didRegisterUserNotificationSettings(id self, SEL _cmd, id applicat
|
|
|
656
739
|
pushwoosh_swizzle([delegate class], @selector(application:didRegisterUserNotificationSettings:), @selector(application:pwplugin_didRegisterUserNotificationSettings:), (IMP)pwplugin_didRegisterUserNotificationSettings, "v@:::");
|
|
657
740
|
}
|
|
658
741
|
|
|
742
|
+
- (NSDictionary*)inboxMessageToDictionary:(NSObject<PWInboxMessageProtocol>*) message {
|
|
743
|
+
NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
|
|
744
|
+
[dictionary setValue:@(message.type) forKey:@"type"];
|
|
745
|
+
[dictionary setValue:[self stringOrEmpty: message.imageUrl] forKey:@"imageUrl"];
|
|
746
|
+
[dictionary setValue:[self stringOrEmpty: message.code] forKey:@"code"];
|
|
747
|
+
[dictionary setValue:[self stringOrEmpty: message.title] forKey:@"title"];
|
|
748
|
+
[dictionary setValue:[self stringOrEmpty: message.message] forKey:@"message"];
|
|
749
|
+
[dictionary setValue:[self stringOrEmpty: [self dateToString:message.sendDate]] forKey:@"sendDate"];
|
|
750
|
+
[dictionary setValue:@(message.isRead) forKey:@"isRead"];
|
|
751
|
+
[dictionary setValue:@(message.isActionPerformed) forKey:@"isActionPerformed"];
|
|
752
|
+
|
|
753
|
+
NSDictionary* actionParams = [NSDictionary dictionaryWithDictionary:message.actionParams];
|
|
754
|
+
NSData* customData = [actionParams valueForKey:@"u"];
|
|
755
|
+
[dictionary setValue:customData forKey:@"customData"];
|
|
756
|
+
|
|
757
|
+
NSDictionary* result = [NSDictionary dictionaryWithDictionary:dictionary];
|
|
758
|
+
return result;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
- (NSString *)stringOrEmpty:(NSString *)string {
|
|
762
|
+
return string != nil ? string : @"";
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
- (NSString*)dateToString:(NSDate*)date {
|
|
766
|
+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
767
|
+
[formatter setDateFormat:@"yyyy-MM-dd'T'H:mm:ssZ"];
|
|
768
|
+
return [formatter stringFromDate:date];
|
|
769
|
+
}
|
|
770
|
+
|
|
659
771
|
- (void)dealloc {
|
|
660
772
|
self.pushManager = nil;
|
|
661
773
|
self.startPushData = nil;
|
|
@@ -14,6 +14,20 @@ type LocalNotification = {
|
|
|
14
14
|
userData?: Object;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
type InboxNotification = {
|
|
18
|
+
code: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
message?: string;
|
|
21
|
+
imageUrl?: string;
|
|
22
|
+
sendDate?: string;
|
|
23
|
+
type?: number;
|
|
24
|
+
bannerUrl?: string;
|
|
25
|
+
customData?: Object;
|
|
26
|
+
isRead?: boolean;
|
|
27
|
+
actionParams?: Object;
|
|
28
|
+
isActionPerformed?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
17
31
|
type AuthOptions = Record<string, number|string>
|
|
18
32
|
|
|
19
33
|
type RemoteNotificationStatus = Record<string,string|number|boolean>
|
|
@@ -39,6 +53,7 @@ export interface PushNotification {
|
|
|
39
53
|
getLaunchNotification(success?: (notification: string) => void): void;
|
|
40
54
|
clearLaunchNotification(success?: () => void): void;
|
|
41
55
|
setUserId(userId: string): void;
|
|
56
|
+
setLanguage(language: string): void;
|
|
42
57
|
postEvent(event: string, attributes?: Record<string, string>): void;
|
|
43
58
|
addJavaScriptInterface(bridgeName: string): void;
|
|
44
59
|
createLocalNotification(notification: LocalNotification, success?: () => void, fail?: () => void): void;
|
|
@@ -50,6 +65,13 @@ export interface PushNotification {
|
|
|
50
65
|
pushReceivedCallback(notification: string): void;
|
|
51
66
|
notificationCallback(notification: string): void;
|
|
52
67
|
presentInboxUI(params?: Record<string,any>): void;
|
|
68
|
+
loadMessages(success?: (messages: InboxNotification[]) =>void, fail?: (error?: Error|string) => void): void;
|
|
69
|
+
messagesWithNoActionPerformedCount(callback: (result: number) => void): void;
|
|
70
|
+
unreadMessagesCount(callback: (result: number) => void): void;
|
|
71
|
+
messagesCount(callback: (result: number) => void): void;
|
|
72
|
+
readMessage(id: string): void;
|
|
73
|
+
deleteMessage(id: string): void;
|
|
74
|
+
performAction(id: string): void;
|
|
53
75
|
showGDPRConsentUI(): void;
|
|
54
76
|
showGDPRDeletionUI(): void;
|
|
55
77
|
setCommunicationEnabled(enable: boolean, success?: () => void, fail?: (callback: Error|string) => void): void;
|
package/www/PushNotification.js
CHANGED
|
@@ -273,6 +273,17 @@ PushNotification.prototype.clearLaunchNotification = function(callback) {
|
|
|
273
273
|
exec(callback, callback, "PushNotification", "clearLaunchNotification", []);
|
|
274
274
|
};
|
|
275
275
|
|
|
276
|
+
//Function: setLanguage
|
|
277
|
+
//[android, ios] Set custom application language (as opposed to the default system language).
|
|
278
|
+
//This allows sending localized push messages
|
|
279
|
+
//
|
|
280
|
+
//Parameters:
|
|
281
|
+
// "language" - string containing language code, i.e. "en", "fr"
|
|
282
|
+
//
|
|
283
|
+
PushNotification.prototype.setLanguage = function(language) {
|
|
284
|
+
exec(null, null, "PushNotification", "setLanguage", [language]);
|
|
285
|
+
};
|
|
286
|
+
|
|
276
287
|
//Function: setUserId
|
|
277
288
|
//[android, ios] Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
|
|
278
289
|
//This allows data and events to be matched across multiple user devices.
|
|
@@ -541,6 +552,41 @@ PushNotification.prototype.presentInboxUI = function(params) {
|
|
|
541
552
|
exec(null, null, "PushNotification", "presentInboxUI", [ params ]);
|
|
542
553
|
}
|
|
543
554
|
|
|
555
|
+
// Load an array of InboxNotification objects
|
|
556
|
+
PushNotification.prototype.loadMessages = function(success, fail) {
|
|
557
|
+
exec(success, fail, "PushNotification", "loadMessages", []);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Get number of inbox messages with no action performed
|
|
561
|
+
PushNotification.prototype.messagesWithNoActionPerformedCount = function(success) {
|
|
562
|
+
exec(success, null, "PushNotification", "messagesWithNoActionPerformedCount", []);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Get number of unread inbox messages
|
|
566
|
+
PushNotification.prototype.unreadMessagesCount = function(success) {
|
|
567
|
+
exec(success, null,"PushNotification", "unreadMessagesCount", []);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// Get total number of inbox messages
|
|
571
|
+
PushNotification.prototype.messagesCount = function(success) {
|
|
572
|
+
exec(success, null,"PushNotification", "messagesCount", []);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Mark inbox message as read
|
|
576
|
+
PushNotification.prototype.readMessage = function(number) {
|
|
577
|
+
exec(null, null, "PushNotification", "readMessage", [number]);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Delete message from inbox
|
|
581
|
+
PushNotification.prototype.deleteMessage = function(number) {
|
|
582
|
+
exec(null, null, "PushNotification", "deleteMessage", [number]);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Perform action for specified inbox message (i.e. open URL)
|
|
586
|
+
PushNotification.prototype.performAction = function(number) {
|
|
587
|
+
exec(null, null, "PushNotification", "performAction", [number]);
|
|
588
|
+
}
|
|
589
|
+
|
|
544
590
|
// Show inApp for change setting Enable/disable all communication with Pushwoosh
|
|
545
591
|
PushNotification.prototype.showGDPRConsentUI = function() {
|
|
546
592
|
exec(null, null, "PushNotification", "showGDPRConsentUI", []);
|