pushwoosh-react-native-plugin 6.1.14 → 6.1.16

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/index.d.ts CHANGED
@@ -10,11 +10,23 @@ declare module 'pushwoosh-react-native-plugin' {
10
10
  userData?: Object;
11
11
  }
12
12
 
13
- interface PushwooshTags {
14
- [index: string]: string | number | string[] | number[]
13
+ type PushwooshTags = Record<string, string | number | string[] | number[] | boolean>
14
+
15
+ type InboxNotification = {
16
+ code: string;
17
+ title?: string;
18
+ message?: string;
19
+ imageUrl?: string;
20
+ sendDate?: string;
21
+ type?: number;
22
+ bannerUrl?: string;
23
+ customData?: Object;
24
+ isRead?: boolean;
25
+ isActionPerformed?: boolean;
15
26
  }
16
27
 
17
28
  interface Pushwoosh {
29
+ //general interaction with Pushwoosh
18
30
  init(config: PushwooshConfig, success?: () => void, fail?: () => void): void;
19
31
  createLocalNotification(notification: LocalNotification): void;
20
32
  clearLocalNotification(): void;
@@ -23,7 +35,7 @@ declare module 'pushwoosh-react-native-plugin' {
23
35
  unregister(success?: (token: string) => void, fail?: (error: Error) => void): void;
24
36
  onPushOpen(callback: () => void, fail?: ()=> void): void;
25
37
  setTags(
26
- tags: Record<string, PushwooshTags>,
38
+ tags: PushwooshTags,
27
39
  success?: () => void,
28
40
  fail?: (error: Error) => void
29
41
  ): void;
@@ -34,16 +46,36 @@ declare module 'pushwoosh-react-native-plugin' {
34
46
  getHwid(success: (hwid: string) => void): void;
35
47
  setUserId(userId: string, success?: ()=> void, fail?: (error: Error) => void): void;
36
48
  postEvent(event: string, attributes?: Record<string, string>): void;
49
+ enableHuaweiPushNotifications(): void;
50
+
51
+ //badge methods
37
52
  setApplicationIconBadgeNumber(badgeNumber: number): void;
38
53
  getApplicationIconBadgeNumber(callback: (badge: number) => void): void;
39
54
  addToApplicationIconBadgeNumber(badgeNumber: number): void;
55
+
56
+ //Notification appearance
40
57
  setMultiNotificationMode(on: boolean): void;
41
58
  setLightScreenOnNotification(on: boolean): void;
42
59
  setEnableLED(on: boolean): void;
43
60
  setColorLED(color: number): void;
44
61
  setSoundType(type: number): void;
45
62
  setVibrateType(type: number): void;
63
+ setNotificationIconBackgroundColor(color: string): void;
64
+ setLanguage(language: string): void;
65
+
66
+ //Inbox API
46
67
  presentInboxUI(style?: Object): void;
68
+ messagesWithNoActionPerformedCount(callback: (result: number) => void): void;
69
+ unreadMessagesCount(callback: (result: number) => void): void;
70
+ messagesCount(callback: (result: number) => void): void;
71
+ loadMessages(success: (notifications: InboxNotification[]) => void, fail?: (error: Error) => void): void;
72
+ readMessage(id: string): void;
73
+ readMessages(ids: string[]): void;
74
+ deleteMessage(id: string): void;
75
+ deleteMessages(ids: string[]): void;
76
+ performAction(id: string): void;
77
+
78
+ //GDPR methods
47
79
  showGDPRConsentUI(): void;
48
80
  showGDPRDeletionUI(): void;
49
81
  isDeviceDataRemoved(success: (isRemoved: boolean) => void): void;
@@ -51,11 +83,8 @@ declare module 'pushwoosh-react-native-plugin' {
51
83
  isAvailableGDPR(success: (isAvailable: boolean) => void): void;
52
84
  setCommunicationEnabled(enabled: boolean, success?: () => void, fail?: (error: Error) => void): void;
53
85
  removeAllDeviceData(success?: () => void, fail?: (error: Error) => void): void;
54
- setNotificationIconBackgroundColor(color: string): void;
55
- setLanguage(language: string): void;
56
- enableHuaweiPushNotifications(): void;
57
86
  }
58
87
 
59
- declare const Pushwoosh: Pushwoosh;
88
+ const Pushwoosh: Pushwoosh;
60
89
  export = Pushwoosh;
61
- }
90
+ }
package/index.js CHANGED
@@ -459,6 +459,45 @@ class PushNotification {
459
459
  PushwooshModule.presentInboxUI(style);
460
460
  }
461
461
 
462
+ messagesWithNoActionPerformedCount(result: Function) {
463
+ PushwooshModule.messagesWithNoActionPerformedCount(result);
464
+ }
465
+
466
+ unreadMessagesCount(result: Function) {
467
+ PushwooshModule.unreadMessagesCount(result);
468
+ }
469
+
470
+ messagesCount(result: Function) {
471
+ PushwooshModule.messagesCount(result);
472
+ }
473
+
474
+ loadMessages(success: Function, fail: ?Function) {
475
+ if (!fail) {
476
+ fail = function() {};
477
+ }
478
+ PushwooshModule.loadMessages(success, fail);
479
+ }
480
+
481
+ readMessage(id: string) {
482
+ PushwooshModule.readMessage(id);
483
+ }
484
+
485
+ readMessages(ids: Array) {
486
+ PushwooshModule.readMessages(ids);
487
+ }
488
+
489
+ deleteMessage(id: string) {
490
+ PushwooshModule.deleteMessage(id);
491
+ }
492
+
493
+ deleteMessages(ids: Array) {
494
+ PushwooshModule.deleteMessages(ids);
495
+ }
496
+
497
+ performAction(id: string) {
498
+ PushwooshModule.performAction(id);
499
+ }
500
+
462
501
  // Show inApp for change setting Enable/disable all communication with Pushwoosh
463
502
  showGDPRConsentUI(){
464
503
  PushwooshModule.showGDPRConsentUI();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-react-native-plugin",
3
- "version": "6.1.14",
3
+ "version": "6.1.16",
4
4
  "description": "This plugin allows you to send and receive push notifications. Powered by Pushwoosh (www.pushwoosh.com).",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = "pushwoosh-react-native-plugin"
3
- s.version = "6.1.14"
3
+ s.version = "6.1.16"
4
4
  s.summary = "React Native Pushwoosh Push Notifications module"
5
5
  s.requires_arc = true
6
6
  s.author = 'Pushwoosh'
@@ -23,10 +23,10 @@ allprojects {
23
23
  apply plugin: 'com.android.library'
24
24
 
25
25
  android {
26
- compileSdkVersion 30
26
+ compileSdkVersion 31
27
27
  defaultConfig {
28
28
  minSdkVersion 17
29
- targetSdkVersion 30
29
+ targetSdkVersion 31
30
30
  }
31
31
  buildTypes {
32
32
  release {
@@ -37,7 +37,7 @@ android {
37
37
  }
38
38
 
39
39
  ext {
40
- pushwoosh = "6.5.2"
40
+ pushwoosh = "6.6.2"
41
41
  }
42
42
 
43
43
  evaluationDependsOn(':app')
@@ -1,5 +1,9 @@
1
1
  package com.pushwoosh.reactnativeplugin;
2
2
 
3
+ import android.os.Bundle;
4
+ import android.util.Log;
5
+
6
+ import java.util.ArrayList;
3
7
  import java.util.Iterator;
4
8
 
5
9
  import com.facebook.react.bridge.ReadableArray;
@@ -10,6 +14,8 @@ import com.facebook.react.bridge.WritableArray;
10
14
  import com.facebook.react.bridge.WritableMap;
11
15
  import com.facebook.react.bridge.WritableNativeArray;
12
16
  import com.facebook.react.bridge.WritableNativeMap;
17
+ import com.pushwoosh.inbox.data.InboxMessage;
18
+ import com.pushwoosh.internal.utils.JsonUtils;
13
19
  import com.pushwoosh.internal.utils.PWLog;
14
20
  import com.pushwoosh.tags.TagsBundle;
15
21
 
@@ -178,4 +184,49 @@ public final class ConversionUtil {
178
184
 
179
185
  return result;
180
186
  }
187
+
188
+ public static WritableMap inboxMessageToWritableMap(InboxMessage message) {
189
+ return toWritableMap(inboxMessageToJson(message));
190
+ }
191
+
192
+ public static JSONObject inboxMessageToJson(InboxMessage message) {
193
+ JSONObject object = new JSONObject();
194
+ try {
195
+ object.put("code", message.getCode())
196
+ .put("title", message.getTitle())
197
+ .put("imageUrl", message.getImageUrl())
198
+ .put("message",message.getMessage())
199
+ .put("sendDate",message.getSendDate().toString())
200
+ .put("type", message.getType().getCode())
201
+ .put("bannerUrl", message.getBannerUrl())
202
+ .put("isRead",message.isRead())
203
+ .put("isActionPerformed",message.isActionPerformed());
204
+
205
+ Bundle bundle = JsonUtils.jsonStringToBundle( message.getActionParams());
206
+ String customData = bundle.getString("u");
207
+ if (customData != null) {
208
+ object.put("customData", customData);
209
+ }
210
+ } catch (JSONException e) {
211
+ Log.e("PushwooshInbox", "Failed to fetch inbox message :" + e.getMessage());
212
+ }
213
+ return object;
214
+ }
215
+
216
+ public static ArrayList<String> messageCodesArrayToArrayList(ReadableArray readableArray) {
217
+ ArrayList<String> result = new ArrayList<>();
218
+ for (int i = 0; i < readableArray.size(); i++) {
219
+ ReadableType indexType = readableArray.getType(i);
220
+ try {
221
+ if (indexType == ReadableType.String) {
222
+ result.add(readableArray.getString(i));
223
+ } else {
224
+ PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".");
225
+ }
226
+ } catch (Exception e) {
227
+ PWLog.error(PushwooshPlugin.TAG, "Could not convert object at index " + i + ".", e);
228
+ }
229
+ }
230
+ return result;
231
+ }
181
232
  }
@@ -7,14 +7,20 @@ import android.content.Intent;
7
7
  import android.graphics.Color;
8
8
  import android.text.TextUtils;
9
9
 
10
+ import androidx.annotation.NonNull;
11
+ import androidx.annotation.Nullable;
12
+
10
13
  import com.facebook.react.bridge.Callback;
11
14
  import com.facebook.react.bridge.LifecycleEventListener;
12
15
  import com.facebook.react.bridge.ReactApplicationContext;
13
16
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
17
  import com.facebook.react.bridge.ReactMethod;
18
+ import com.facebook.react.bridge.ReadableArray;
15
19
  import com.facebook.react.bridge.ReadableMap;
20
+ import com.facebook.react.bridge.WritableNativeArray;
16
21
  import com.pushwoosh.GDPRManager;
17
22
  import com.pushwoosh.Pushwoosh;
23
+ import com.pushwoosh.RegisterForPushNotificationsResultData;
18
24
  import com.pushwoosh.badge.PushwooshBadge;
19
25
  import com.pushwoosh.exception.GetTagsException;
20
26
  import com.pushwoosh.exception.PushwooshException;
@@ -23,6 +29,9 @@ import com.pushwoosh.exception.RegisterForPushNotificationsException;
23
29
  import com.pushwoosh.exception.UnregisterForPushNotificationException;
24
30
  import com.pushwoosh.function.Result;
25
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;
26
35
  import com.pushwoosh.inbox.ui.presentation.view.activity.InboxActivity;
27
36
  import com.pushwoosh.internal.network.NetworkModule;
28
37
  import com.pushwoosh.internal.platform.AndroidPlatformModule;
@@ -36,6 +45,9 @@ import com.pushwoosh.notification.LocalNotificationReceiver;
36
45
 
37
46
  import org.json.JSONObject;
38
47
 
48
+ import java.util.ArrayList;
49
+ import java.util.Collection;
50
+
39
51
  public class PushwooshPlugin extends ReactContextBaseJavaModule implements LifecycleEventListener {
40
52
 
41
53
  static final String TAG = "ReactNativePlugin";
@@ -351,6 +363,92 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
351
363
  }
352
364
  }
353
365
 
366
+ @ReactMethod
367
+ public void messagesWithNoActionPerformedCount(final Callback callback) {
368
+ PushwooshInbox.messagesWithNoActionPerformedCount(new com.pushwoosh.function.Callback<Integer, InboxMessagesException>() {
369
+ @Override
370
+ public void process(@NonNull Result<Integer, InboxMessagesException> result) {
371
+ if (result.isSuccess() && callback != null) {
372
+ callback.invoke(result.getData());
373
+ }
374
+ }
375
+ });
376
+ }
377
+
378
+ @ReactMethod
379
+ public void unreadMessagesCount(final Callback callback) {
380
+ PushwooshInbox.unreadMessagesCount(new com.pushwoosh.function.Callback<Integer, InboxMessagesException>() {
381
+ @Override
382
+ public void process(@NonNull Result<Integer, InboxMessagesException> result) {
383
+ if (result.isSuccess() && callback != null) {
384
+ callback.invoke(result.getData());
385
+ }
386
+ }
387
+ });
388
+ }
389
+
390
+ @ReactMethod
391
+ public void messagesCount(final Callback callback) {
392
+ PushwooshInbox.messagesCount(new com.pushwoosh.function.Callback<Integer, InboxMessagesException>() {
393
+ @Override
394
+ public void process(@NonNull Result<Integer, InboxMessagesException> result) {
395
+ if (result.isSuccess() && callback != null) {
396
+ callback.invoke(result.getData());
397
+ }
398
+ }
399
+ });
400
+ }
401
+
402
+ @ReactMethod
403
+ public void loadMessages(@NonNull final Callback success, @Nullable final Callback error) {
404
+ PushwooshInbox.loadMessages(new com.pushwoosh.function.Callback<Collection<InboxMessage>, InboxMessagesException>() {
405
+ @Override
406
+ public void process(@NonNull Result<Collection<InboxMessage>, InboxMessagesException> result) {
407
+ try {
408
+ if (result.isSuccess() && result.getData() != null) {
409
+ ArrayList<InboxMessage> messagesList = new ArrayList<>(result.getData());
410
+ WritableNativeArray writableArray = new WritableNativeArray();
411
+ for (InboxMessage message : messagesList) {
412
+ writableArray.pushMap(ConversionUtil.inboxMessageToWritableMap(message));
413
+ }
414
+ success.invoke(writableArray);
415
+ } else if (error != null) {
416
+ error.invoke(TAG + "Failed to fetch inbox messages from server");
417
+ }
418
+ } catch (Exception e) {
419
+ if (error != null) {
420
+ error.invoke(e.getLocalizedMessage());
421
+ }
422
+ }
423
+ }
424
+ });
425
+ }
426
+
427
+ @ReactMethod
428
+ public void readMessage(String id) {
429
+ PushwooshInbox.readMessage(id);
430
+ }
431
+
432
+ @ReactMethod
433
+ public void readMessages(ReadableArray codes) {
434
+ PushwooshInbox.readMessages(ConversionUtil.messageCodesArrayToArrayList(codes));
435
+ }
436
+
437
+ @ReactMethod
438
+ public void deleteMessage(String id) {
439
+ PushwooshInbox.deleteMessage(id);
440
+ }
441
+
442
+ @ReactMethod
443
+ public void deleteMessages(ReadableArray codes) {
444
+ PushwooshInbox.deleteMessages(ConversionUtil.messageCodesArrayToArrayList(codes));
445
+ }
446
+
447
+ @ReactMethod
448
+ public void performAction(String id) {
449
+ PushwooshInbox.performAction(id);
450
+ }
451
+
354
452
  @ReactMethod
355
453
  public void showGDPRConsentUI(){
356
454
  GDPRManager.getInstance().showGDPRConsentUI();
@@ -504,7 +602,7 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
504
602
  }
505
603
  }
506
604
 
507
- private class RegisterForPushNotificationCallback implements com.pushwoosh.function.Callback<String, RegisterForPushNotificationsException> {
605
+ private class RegisterForPushNotificationCallback implements com.pushwoosh.function.Callback<RegisterForPushNotificationsResultData, RegisterForPushNotificationsException> {
508
606
  private Callback success;
509
607
  private Callback error;
510
608
 
@@ -514,10 +612,10 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
514
612
  }
515
613
 
516
614
  @Override
517
- public void process(Result<String, RegisterForPushNotificationsException> result) {
615
+ public void process(Result<RegisterForPushNotificationsResultData, RegisterForPushNotificationsException> result) {
518
616
  if (result.isSuccess()) {
519
- if (success != null) {
520
- success.invoke(result.getData());
617
+ if (success != null && result.getData() != null) {
618
+ success.invoke(result.getData().getToken());
521
619
  success = null;
522
620
  }
523
621
  } else if (result.getException() != null) {
@@ -18,15 +18,15 @@
18
18
 
19
19
  #endif
20
20
 
21
- #define PUSHWOOSH_VERSION @"6.4.2"
21
+ #define PUSHWOOSH_VERSION @"6.4.5"
22
22
 
23
23
 
24
24
  @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy;
25
25
 
26
26
 
27
- typedef void (^PushwooshRegistrationHandler)(NSString *token, NSError *error);
28
- typedef void (^PushwooshGetTagsHandler)(NSDictionary *tags);
29
- typedef void (^PushwooshErrorHandler)(NSError *error);
27
+ typedef void (^PushwooshRegistrationHandler)(NSString * _Nullable token, NSError * _Nullable error);
28
+ typedef void (^PushwooshGetTagsHandler)(NSDictionary * _Nullable tags);
29
+ typedef void (^PushwooshErrorHandler)(NSError * _Nullable error);
30
30
 
31
31
 
32
32
  /**
@@ -43,7 +43,7 @@ typedef void (^PushwooshErrorHandler)(NSError *error);
43
43
  @param pushwoosh The push manager that received the remote notification.
44
44
  @param message A PWMessage object that contains information referring to the remote notification, potentially including a badge number for the application icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data.
45
45
  */
46
- - (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageReceived:(PWMessage *)message;
46
+ - (void)pushwoosh:(Pushwoosh * _Nonnull)pushwoosh onMessageReceived:(PWMessage * _Nonnull)message;
47
47
 
48
48
  /**
49
49
  Tells the delegate that the user has pressed on the push notification banner.
@@ -51,7 +51,32 @@ Tells the delegate that the user has pressed on the push notification banner.
51
51
  @param pushwoosh The push manager that received the remote notification.
52
52
  @param message A PWMessage object that contains information about the remote notification, potentially including a badge number for the application icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data.
53
53
  */
54
- - (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageOpened:(PWMessage *)message;
54
+ - (void)pushwoosh:(Pushwoosh * _Nonnull)pushwoosh onMessageOpened:(PWMessage * _Nonnull)message;
55
+
56
+ @end
57
+
58
+ /**
59
+ `PWPurchaseDelegate` protocol defines the methods that can be implemented in the delegate of the `Pushwoosh` class' singleton object.
60
+ These methods provide callbacks for events related to purchasing In-App products from rich medias, such as successful purchase event, failed payment, etc.
61
+ These methods implementation allows to react on such events properly.
62
+ */
63
+
64
+ @protocol PWPurchaseDelegate <NSObject>
65
+
66
+ //list of products
67
+ -(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products;
68
+
69
+ //payment complete
70
+ -(void)onPWInAppPurchaseHelperPaymentComplete:(NSString* _Nullable)identifier;
71
+
72
+ //payment failed
73
+ -(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error;
74
+
75
+ //promoted In-App purchase
76
+ -(void)onPWInAppPurchaseHelperCallPromotedPurchase:(NSString* _Nullable)identifier;
77
+
78
+ //Tells the observer that an error occurred while restoring transactions.
79
+ -(void)onPWInAppPurchaseHelperRestoreCompletedTransactionsFailed:(NSError * _Nullable)error;
55
80
 
56
81
  @end
57
82
 
@@ -64,17 +89,17 @@ Tells the delegate that the user has pressed on the push notification banner.
64
89
  /**
65
90
  Title of the push message.
66
91
  */
67
- @property (nonatomic, readonly) NSString *title;
92
+ @property (nonatomic, readonly) NSString * _Nullable title;
68
93
 
69
94
  /**
70
95
  Subtitle of the push message.
71
96
  */
72
- @property (nonatomic, readonly) NSString *subTitle;
97
+ @property (nonatomic, readonly) NSString * _Nullable subTitle;
73
98
 
74
99
  /**
75
100
  Body of the push message.
76
101
  */
77
- @property (nonatomic, readonly) NSString *message;
102
+ @property (nonatomic, readonly) NSString * _Nullable message;
78
103
 
79
104
  /**
80
105
  Badge number of the push message.
@@ -89,7 +114,7 @@ Tells the delegate that the user has pressed on the push notification banner.
89
114
  /**
90
115
  Remote URL or deeplink from the push message.
91
116
  */
92
- @property (nonatomic, readonly) NSString *link;
117
+ @property (nonatomic, readonly) NSString * _Nullable link;
93
118
 
94
119
  /**
95
120
  Returns YES if this message received/opened then the app is in foreground state.
@@ -109,17 +134,17 @@ Tells the delegate that the user has pressed on the push notification banner.
109
134
  /**
110
135
  Gets custom JSON data from push notifications dictionary as specified in Pushwoosh Control Panel.
111
136
  */
112
- @property (nonatomic, readonly) NSDictionary *customData;
137
+ @property (nonatomic, readonly) NSDictionary * _Nullable customData;
113
138
 
114
139
  /**
115
140
  Original payload of the message.
116
141
  */
117
- @property (nonatomic, readonly) NSDictionary *payload;
142
+ @property (nonatomic, readonly) NSDictionary * _Nullable payload;
118
143
 
119
144
  /**
120
145
  Returns YES if this message is recieved from Pushwoosh.
121
146
  */
122
- + (BOOL)isPushwooshMessage:(NSDictionary *)userInfo;
147
+ + (BOOL)isPushwooshMessage:(NSDictionary *_Nonnull)userInfo;
123
148
 
124
149
  @end
125
150
 
@@ -132,13 +157,18 @@ Tells the delegate that the user has pressed on the push notification banner.
132
157
  /**
133
158
  Pushwoosh Application ID. Usually retrieved automatically from Info.plist parameter `Pushwoosh_APPID`
134
159
  */
135
- @property (nonatomic, copy, readonly) NSString *applicationCode;
160
+ @property (nonatomic, copy, readonly) NSString * _Nonnull applicationCode;
136
161
 
137
162
  /**
138
163
  `PushNotificationDelegate` protocol delegate that would receive the information about events for push notification manager such as registering with APS services, receiving push notifications or working with the received notification.
139
164
  Pushwoosh Runtime sets it to ApplicationDelegate by default
140
165
  */
141
- @property (nonatomic, weak) NSObject<PWMessagingDelegate> *delegate;
166
+ @property (nonatomic, weak) NSObject<PWMessagingDelegate> * _Nullable delegate;
167
+
168
+ /**
169
+ `PushPurchaseDelegate` protocol delegate that would receive the information about events related to purchasing InApp products from rich medias
170
+ */
171
+ @property (nonatomic, weak) NSObject<PWPurchaseDelegate> * _Nullable purchaseDelegate;
142
172
 
143
173
  #if TARGET_OS_IOS || TARGET_OS_WATCH
144
174
 
@@ -157,62 +187,62 @@ Tells the delegate that the user has pressed on the push notification banner.
157
187
  /**
158
188
  Returns push notification payload if the app was started in response to push notification or null otherwise
159
189
  */
160
- @property (nonatomic, copy, readonly) NSDictionary *launchNotification;
190
+ @property (nonatomic, copy, readonly) NSDictionary * _Nullable launchNotification;
161
191
 
162
192
  /**
163
193
  Proxy contains UNUserNotificationCenterDelegate objects.
164
194
  */
165
- @property (nonatomic, readonly) PWNotificationCenterDelegateProxy *notificationCenterDelegateProxy;
195
+ @property (nonatomic, readonly) PWNotificationCenterDelegateProxy * _Nullable notificationCenterDelegateProxy;
166
196
 
167
197
  /**
168
198
  Set custom application language. Must be a lowercase two-letter code according to ISO-639-1 standard ("en", "de", "fr", etc.).
169
199
  Device language used by default.
170
200
  Set to nil if you want to use device language again.
171
201
  */
172
- @property (nonatomic) NSString *language;
202
+ @property (nonatomic) NSString * _Nonnull language;
173
203
 
174
204
  /**
175
205
  Initializes Pushwoosh.
176
206
  @param appCode Pushwoosh App ID.
177
207
  */
178
- + (void)initializeWithAppCode:(NSString *)appCode;
208
+ + (void)initializeWithAppCode:(NSString *_Nonnull)appCode;
179
209
 
180
210
  /**
181
211
  Returns an object representing the current push manager.
182
212
 
183
213
  @return A singleton object that represents the push manager.
184
214
  */
185
- + (instancetype)sharedInstance;
215
+ + (instancetype _Nonnull )sharedInstance;
186
216
 
187
217
  /**
188
218
  Registers for push notifications. By default registeres for "UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert" flags.
189
219
  Automatically detects if you have "newsstand-content" in "UIBackgroundModes" and adds "UIRemoteNotificationTypeNewsstandContentAvailability" flag.
190
220
  */
191
221
  - (void)registerForPushNotifications;
192
- - (void)registerForPushNotificationsWithCompletion:(PushwooshRegistrationHandler)completion;
222
+ - (void)registerForPushNotificationsWithCompletion:(PushwooshRegistrationHandler _Nullable )completion;
193
223
 
194
224
  /**
195
225
  Unregisters from push notifications.
196
226
  */
197
227
  - (void)unregisterForPushNotifications;
198
- - (void)unregisterForPushNotificationsWithCompletion:(void (^)(NSError *error))completion;
228
+ - (void)unregisterForPushNotificationsWithCompletion:(void (^_Nullable)(NSError * _Nullable error))completion;
199
229
 
200
230
  /**
201
231
  Handle registration to remote notifications.
202
232
  */
203
- - (void)handlePushRegistration:(NSData *)devToken;
204
- - (void)handlePushRegistrationFailure:(NSError *)error;
233
+ - (void)handlePushRegistration:(NSData * _Nonnull)devToken;
234
+ - (void)handlePushRegistrationFailure:(NSError * _Nonnull)error;
205
235
 
206
236
  /**
207
237
  Handle received push notification.
208
238
  */
209
- - (BOOL)handlePushReceived:(NSDictionary *)userInfo;
239
+ - (BOOL)handlePushReceived:(NSDictionary * _Nonnull)userInfo;
210
240
 
211
241
  /**
212
242
  * Change default base url to reverse proxy url
213
243
  * @param url - reverse proxy url
214
244
  */
215
- - (void)setReverseProxy:(NSString *)url;
245
+ - (void)setReverseProxy:(NSString * _Nonnull)url;
216
246
 
217
247
  /**
218
248
  * Disables reverse proxy
@@ -235,16 +265,16 @@ Unregisters from push notifications.
235
265
 
236
266
  @param tags Dictionary representation of tags to send.
237
267
  */
238
- - (void)setTags:(NSDictionary *)tags;
268
+ - (void)setTags:(NSDictionary * _Nonnull)tags;
239
269
 
240
270
  /**
241
271
  Send tags to server with completion block. If setTags succeeds competion is called with nil argument. If setTags fails completion is called with error.
242
272
  */
243
- - (void)setTags:(NSDictionary *)tags completion:(void (^)(NSError *error))completion;
273
+ - (void)setTags:(NSDictionary * _Nonnull)tags completion:(void (^_Nullable)(NSError * _Nullable error))completion;
244
274
 
245
- - (void)setEmailTags:(NSDictionary *)tags forEmail:(NSString *)email;
275
+ - (void)setEmailTags:(NSDictionary * _Nonnull)tags forEmail:(NSString * _Nonnull)email;
246
276
 
247
- - (void)setEmailTags:(NSDictionary *)tags forEmail:(NSString *)email completion:(void(^)(NSError *error))completion;
277
+ - (void)setEmailTags:(NSDictionary * _Nonnull)tags forEmail:(NSString * _Nonnull)email completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
248
278
 
249
279
  /**
250
280
  Get tags from server. Calls delegate method if exists and handler (block).
@@ -257,7 +287,7 @@ Unregisters from push notifications.
257
287
  }
258
288
  @param errorHandler The block is executed on the unsuccessful completion of the request. This block has no return value and takes one argument: the error that occurred during the request.
259
289
  */
260
- - (void)getTags:(PushwooshGetTagsHandler)successHandler onFailure:(PushwooshErrorHandler)errorHandler;
290
+ - (void)getTags:(PushwooshGetTagsHandler _Nullable)successHandler onFailure:(PushwooshErrorHandler _Nullable)errorHandler;
261
291
 
262
292
  /**
263
293
  Sends current badge value to server. Called internally by SDK Runtime when `UIApplication` `setApplicationBadgeNumber:` is set. This function is used for "auto-incremeting" badges to work.
@@ -270,7 +300,7 @@ Unregisters from push notifications.
270
300
  /**
271
301
  Pushwoosh SDK version.
272
302
  */
273
- + (NSString *)version;
303
+ + (NSString * _Nonnull)version;
274
304
 
275
305
  #if TARGET_OS_IOS
276
306
  /**
@@ -285,7 +315,7 @@ Unregisters from push notifications.
285
315
 
286
316
  @param transactions Array of SKPaymentTransaction items as received in the payment queue.
287
317
  */
288
- - (void)sendSKPaymentTransactions:(NSArray *)transactions;
318
+ - (void)sendSKPaymentTransactions:(NSArray * _Nonnull)transactions;
289
319
 
290
320
  /**
291
321
  Tracks individual in-app purchase. See recommended `sendSKPaymentTransactions:` method.
@@ -295,7 +325,7 @@ Unregisters from push notifications.
295
325
  @param currencyCode currency of the price (ex: @"USD")
296
326
  @param date time of the purchase (ex: [NSDate now])
297
327
  */
298
- - (void)sendPurchase:(NSString *)productIdentifier withPrice:(NSDecimalNumber *)price currencyCode:(NSString *)currencyCode andDate:(NSDate *)date;
328
+ - (void)sendPurchase:(NSString * _Nonnull)productIdentifier withPrice:(NSDecimalNumber * _Nonnull)price currencyCode:(NSString * _Nonnull)currencyCode andDate:(NSDate * _Nonnull)date;
299
329
 
300
330
  #endif
301
331
  /**
@@ -303,7 +333,7 @@ Unregisters from push notifications.
303
333
 
304
334
  @return Current push token. May be nil if no push token is available yet.
305
335
  */
306
- - (NSString *)getPushToken;
336
+ - (NSString * _Nullable)getPushToken;
307
337
 
308
338
  /**
309
339
  Gets HWID. Unique device identifier that used in all API calls with Pushwoosh.
@@ -311,7 +341,7 @@ Unregisters from push notifications.
311
341
 
312
342
  @return Unique device identifier.
313
343
  */
314
- - (NSString *)getHWID;
344
+ - (NSString * _Nonnull)getHWID;
315
345
 
316
346
  /**
317
347
  Returns dictionary with enabled remove notificaton types.
@@ -341,7 +371,7 @@ Unregisters from push notifications.
341
371
 
342
372
  Note: In the latter example "enabled" field means that device can receive push notification but could not display alerts (ex: silent push)
343
373
  */
344
- + (NSMutableDictionary *)getRemoteNotificationStatus;
374
+ + (NSMutableDictionary * _Nullable)getRemoteNotificationStatus;
345
375
 
346
376
  /**
347
377
  Clears the notifications from the notification center.
@@ -355,7 +385,7 @@ Unregisters from push notifications.
355
385
 
356
386
  @param userId user identifier
357
387
  */
358
- - (void)setUserId:(NSString *)userId completion:(void(^)(NSError * error))completion;
388
+ - (void)setUserId:(NSString * _Nonnull)userId completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
359
389
 
360
390
  /**
361
391
  Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
@@ -363,7 +393,7 @@ Unregisters from push notifications.
363
393
 
364
394
  @param userId user identifier
365
395
  */
366
- - (void)setUserId:(NSString *)userId;
396
+ - (void)setUserId:(NSString * _Nonnull)userId;
367
397
 
368
398
  /**
369
399
  Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
@@ -373,7 +403,7 @@ Unregisters from push notifications.
373
403
  @param userId user identifier
374
404
  @param emails user's emails array
375
405
  */
376
- - (void)setUser:(NSString *)userId emails:(NSArray *)emails completion:(void(^)(NSError * error))completion;
406
+ - (void)setUser:(NSString * _Nonnull)userId emails:(NSArray * _Nonnull)emails completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
377
407
 
378
408
 
379
409
  /**
@@ -383,7 +413,7 @@ Unregisters from push notifications.
383
413
  @param userId user identifier
384
414
  @param emails user's emails array
385
415
  */
386
- - (void)setUser:(NSString *)userId emails:(NSArray *)emails;
416
+ - (void)setUser:(NSString * _Nonnull)userId emails:(NSArray * _Nonnull)emails;
387
417
 
388
418
  /**
389
419
  Set User indentifier. This could be Facebook ID, username or email, or any other user ID.
@@ -393,7 +423,7 @@ Unregisters from push notifications.
393
423
  @param userId user identifier
394
424
  @param email user's email string
395
425
  */
396
- - (void)setUser:(NSString *)userId email:(NSString *)email completion:(void(^)(NSError * error))completion;
426
+ - (void)setUser:(NSString * _Nonnull)userId email:(NSString * _Nonnull)email completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
397
427
 
398
428
  /**
399
429
  Register emails list associated to the current user.
@@ -401,14 +431,14 @@ Unregisters from push notifications.
401
431
 
402
432
  @param emails user's emails array
403
433
  */
404
- - (void)setEmails:(NSArray *)emails completion:(void(^)(NSError * error))completion;
434
+ - (void)setEmails:(NSArray * _Nonnull)emails completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
405
435
 
406
436
  /**
407
437
  Register emails list associated to the current user.
408
438
 
409
439
  @param emails user's emails array
410
440
  */
411
- - (void)setEmails:(NSArray *)emails;
441
+ - (void)setEmails:(NSArray * _Nonnull)emails;
412
442
 
413
443
  /**
414
444
  Register email associated to the current user. Email should be a string and could not be null or empty.
@@ -416,14 +446,14 @@ Unregisters from push notifications.
416
446
 
417
447
  @param email user's email string
418
448
  */
419
- - (void)setEmail:(NSString *)email completion:(void(^)(NSError * error))completion;
449
+ - (void)setEmail:(NSString * _Nonnull)email completion:(void(^ _Nullable)(NSError * _Nullable error))completion;
420
450
 
421
451
  /**
422
452
  Register email associated to the current user. Email should be a string and could not be null or empty.
423
453
 
424
454
  @param email user's email string
425
455
  */
426
- - (void)setEmail:(NSString *)email;
456
+ - (void)setEmail:(NSString * _Nonnull)email;
427
457
 
428
458
  /**
429
459
  Move all events from oldUserId to newUserId if doMerge is true. If doMerge is false all events for oldUserId are removed.
@@ -433,7 +463,7 @@ Unregisters from push notifications.
433
463
  @param doMerge if false all events for oldUserId are removed, if true all events for oldUserId are moved to newUserId
434
464
  @param completion callback
435
465
  */
436
- - (void)mergeUserId:(NSString *)oldUserId to:(NSString *)newUserId doMerge:(BOOL)doMerge completion:(void (^)(NSError *error))completion;
466
+ - (void)mergeUserId:(NSString * _Nonnull)oldUserId to:(NSString * _Nonnull)newUserId doMerge:(BOOL)doMerge completion:(void (^ _Nullable)(NSError * _Nullable error))completion;
437
467
 
438
468
  /**
439
469
  Starts communication with Pushwoosh server.
@@ -451,7 +481,7 @@ Unregisters from push notifications.
451
481
  @param url Deep Link URL
452
482
  */
453
483
  #if TARGET_OS_IOS || TARGET_OS_WATCH
454
- - (BOOL)handleOpenURL:(NSURL *)url;
484
+ - (BOOL)handleOpenURL:(NSURL * _Nonnull)url;
455
485
  #endif
456
486
 
457
487
  @end
@@ -468,7 +498,7 @@ Unregisters from push notifications.
468
498
  Returns UNUserNotificationCenterDelegate that handles foreground push notifications on iOS10
469
499
  */
470
500
  #if TARGET_OS_IOS || TARGET_OS_WATCH
471
- @property (nonatomic, strong, readonly) id<UNUserNotificationCenterDelegate> defaultNotificationCenterDelegate;
501
+ @property (nonatomic, strong, readonly) id<UNUserNotificationCenterDelegate> _Nonnull defaultNotificationCenterDelegate;
472
502
  #elif TARGET_OS_OSX
473
503
  @property (nonatomic, strong, readonly) id<NSUserNotificationCenterDelegate> defaultNotificationCenterDelegate;
474
504
  #endif
@@ -477,7 +507,7 @@ Unregisters from push notifications.
477
507
  Adds extra UNUserNotificationCenterDelegate that handles foreground push notifications on iOS10.
478
508
  */
479
509
  #if TARGET_OS_IOS || TARGET_OS_WATCH
480
- - (void)addNotificationCenterDelegate:(id<UNUserNotificationCenterDelegate>)delegate;
510
+ - (void)addNotificationCenterDelegate:(id<UNUserNotificationCenterDelegate> _Nonnull)delegate;
481
511
  #endif
482
512
  @end
483
513
 
@@ -504,7 +534,7 @@ Unregisters from push notifications.
504
534
 
505
535
  @return Dictionary, that needs to be sent as the value for the tag
506
536
  */
507
- + (NSDictionary *)incrementalTagWithInteger:(NSInteger)delta;
537
+ + (NSDictionary * _Nullable)incrementalTagWithInteger:(NSInteger)delta;
508
538
 
509
539
  /**
510
540
  Creates a dictionary for extending Tag’s values list with additional values
@@ -525,6 +555,6 @@ Unregisters from push notifications.
525
555
 
526
556
  @return Dictionary to be sent as the value for the tag
527
557
  */
528
- + (NSDictionary *)appendValuesToListTag:(NSArray<NSString *> *)array;
558
+ + (NSDictionary * _Nullable)appendValuesToListTag:(NSArray<NSString *> * _Nonnull)array;
529
559
 
530
560
  @end
@@ -42,25 +42,25 @@ RCT_EXPORT_MODULE(Pushwoosh);
42
42
  }
43
43
 
44
44
  RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)success error:(RCTResponseSenderBlock)error) {
45
- NSString *appCode = config[@"pw_appid"];
45
+ NSString *appCode = config[@"pw_appid"];
46
46
  NSString *notificationHandling = config[@"pw_notification_handling"];
47
47
 
48
- if (!appCode || ![appCode isKindOfClass:[NSString class]]) {
49
- if (error) {
50
- error(@[ @"pw_appid is missing" ]);
51
- }
52
-
53
- return;
54
- }
48
+ if (!appCode || ![appCode isKindOfClass:[NSString class]]) {
49
+ if (error) {
50
+ error(@[ @"pw_appid is missing" ]);
51
+ }
52
+
53
+ return;
54
+ }
55
55
 
56
56
  NSString *proxyUrl = config[@"reverse_proxy_url"];
57
57
  if (proxyUrl && ![proxyUrl isEqualToString:@""]) {
58
58
  [[Pushwoosh sharedInstance] setReverseProxy:proxyUrl];
59
59
  }
60
60
 
61
- [PushNotificationManager initializeWithAppCode:appCode appName:nil];
62
- [[PushNotificationManager pushManager] sendAppOpen];
63
- [PushNotificationManager pushManager].delegate = self;
61
+ [PushNotificationManager initializeWithAppCode:appCode appName:nil];
62
+ [[PushNotificationManager pushManager] sendAppOpen];
63
+ [PushNotificationManager pushManager].delegate = self;
64
64
 
65
65
  // We set Pushwoosh UNUserNotificationCenter delegate unless CUSTOM is specified in the config
66
66
  if(![notificationHandling isEqualToString:@"CUSTOM"]) {
@@ -71,7 +71,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
71
71
  success(@[]);
72
72
  }
73
73
 
74
- if (gStartPushData) {
74
+ if (gStartPushData) {
75
75
  NSString *link = gStartPushData[@"l"];
76
76
 
77
77
  //get deeplink from the payload and write it to the launchOptions for proper RCTLinking behavior
@@ -82,7 +82,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
82
82
  }
83
83
 
84
84
  [self sendJSEvent:kPushReceivedJSEvent withArgs:gStartPushData];
85
- [self sendJSEvent:kPushOpenJSEvent withArgs:gStartPushData];
85
+ [self sendJSEvent:kPushOpenJSEvent withArgs:gStartPushData];
86
86
  } else if([PushNotificationManager pushManager].launchNotification) {
87
87
  [self sendJSEvent:kPushReceivedJSEvent withArgs:[PushNotificationManager pushManager].launchNotification];
88
88
  [self sendJSEvent:kPushOpenJSEvent withArgs:[PushNotificationManager pushManager].launchNotification];
@@ -90,10 +90,10 @@ RCT_EXPORT_METHOD(init:(NSDictionary*)config success:(RCTResponseSenderBlock)suc
90
90
  }
91
91
 
92
92
  RCT_EXPORT_METHOD(register:(RCTResponseSenderBlock)success error:(RCTResponseSenderBlock)error) {
93
- [[PWEventDispatcher sharedDispatcher] subscribe:success toEvent:kRegistrationSuccesEvent];
94
- [[PWEventDispatcher sharedDispatcher] subscribe:error toEvent:kRegistrationErrorEvent];
95
-
96
- [[PushNotificationManager pushManager] registerForPushNotifications];
93
+ [[PWEventDispatcher sharedDispatcher] subscribe:success toEvent:kRegistrationSuccesEvent];
94
+ [[PWEventDispatcher sharedDispatcher] subscribe:error toEvent:kRegistrationErrorEvent];
95
+
96
+ [[PushNotificationManager pushManager] registerForPushNotifications];
97
97
  }
98
98
 
99
99
  RCT_EXPORT_METHOD(unregister:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
@@ -109,13 +109,13 @@ RCT_EXPORT_METHOD(unregister:(RCTResponseSenderBlock)successCallback error:(RCTR
109
109
  }
110
110
 
111
111
  RCT_EXPORT_METHOD(onPushOpen:(RCTResponseSenderBlock)callback) {
112
- [[PWEventDispatcher sharedDispatcher] subscribe:callback toEvent:kPushOpenEvent];
113
-
114
- if (gStartPushData) {
115
- NSDictionary *pushData = gStartPushData;
116
- gStartPushData = nil;
117
- [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushData) ]];
118
- }
112
+ [[PWEventDispatcher sharedDispatcher] subscribe:callback toEvent:kPushOpenEvent];
113
+
114
+ if (gStartPushData) {
115
+ NSDictionary *pushData = gStartPushData;
116
+ gStartPushData = nil;
117
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushData) ]];
118
+ }
119
119
  }
120
120
 
121
121
  RCT_EXPORT_METHOD(onPushReceived:(RCTResponseSenderBlock)callback) {
@@ -129,39 +129,39 @@ RCT_EXPORT_METHOD(onPushReceived:(RCTResponseSenderBlock)callback) {
129
129
  }
130
130
 
131
131
  RCT_EXPORT_METHOD(getHwid:(RCTResponseSenderBlock)callback) {
132
- if (callback) {
133
- callback(@[ [[PushNotificationManager pushManager] getHWID] ]);
134
- }
132
+ if (callback) {
133
+ callback(@[ [[PushNotificationManager pushManager] getHWID] ]);
134
+ }
135
135
  }
136
136
 
137
137
  RCT_EXPORT_METHOD(getPushToken:(RCTResponseSenderBlock)callback) {
138
- if (callback) {
139
- callback(@[ objectOrNull([[PushNotificationManager pushManager] getPushToken]) ]);
140
- }
138
+ if (callback) {
139
+ callback(@[ objectOrNull([[PushNotificationManager pushManager] getPushToken]) ]);
140
+ }
141
141
  }
142
142
 
143
143
  RCT_EXPORT_METHOD(setTags:(NSDictionary*)tags success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
144
- [[PushNotificationManager pushManager] setTags:tags withCompletion:^(NSError* error) {
145
- if (!error && successCallback) {
146
- successCallback(@[]);
147
- }
148
-
149
- if (error && errorCallback) {
150
- errorCallback(@[ objectOrNull([error localizedDescription]) ]);
151
- }
152
- }];
144
+ [[PushNotificationManager pushManager] setTags:tags withCompletion:^(NSError* error) {
145
+ if (!error && successCallback) {
146
+ successCallback(@[]);
147
+ }
148
+
149
+ if (error && errorCallback) {
150
+ errorCallback(@[ objectOrNull([error localizedDescription]) ]);
151
+ }
152
+ }];
153
153
  }
154
154
 
155
155
  RCT_EXPORT_METHOD(getTags:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
156
- [[PushNotificationManager pushManager] loadTags:^(NSDictionary* tags) {
157
- if (successCallback) {
158
- successCallback(@[ tags ]);
159
- }
160
- } error:^(NSError *error) {
161
- if (errorCallback) {
162
- errorCallback(@[ objectOrNull([error localizedDescription]) ]);
163
- }
164
- }];
156
+ [[PushNotificationManager pushManager] loadTags:^(NSDictionary* tags) {
157
+ if (successCallback) {
158
+ successCallback(@[ tags ]);
159
+ }
160
+ } error:^(NSError *error) {
161
+ if (errorCallback) {
162
+ errorCallback(@[ objectOrNull([error localizedDescription]) ]);
163
+ }
164
+ }];
165
165
  }
166
166
 
167
167
  RCT_EXPORT_METHOD(setShowPushnotificationAlert:(BOOL)showPushnotificationAlert) {
@@ -175,7 +175,7 @@ RCT_EXPORT_METHOD(getShowPushnotificationAlert:(RCTResponseSenderBlock)callback)
175
175
  }
176
176
 
177
177
  RCT_EXPORT_METHOD(setUserId:(NSString*)userId) {
178
- [[PWInAppManager sharedManager] setUserId:userId];
178
+ [[PWInAppManager sharedManager] setUserId:userId];
179
179
  }
180
180
 
181
181
  RCT_EXPORT_METHOD(setUserId:(NSString*)userId success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
@@ -192,7 +192,7 @@ RCT_EXPORT_METHOD(setUserId:(NSString*)userId success:(RCTResponseSenderBlock)su
192
192
  }
193
193
 
194
194
  RCT_EXPORT_METHOD(postEvent:(NSString*)event withAttributes:(NSDictionary*)attributes) {
195
- [[PWInAppManager sharedManager] postEvent:event withAttributes:attributes];
195
+ [[PWInAppManager sharedManager] postEvent:event withAttributes:attributes];
196
196
  }
197
197
 
198
198
  RCT_EXPORT_METHOD(setApplicationIconBadgeNumber:(nonnull NSNumber*)badgeNumber) {
@@ -206,11 +206,11 @@ RCT_EXPORT_METHOD(setLanguage:(NSString *)language) {
206
206
  }
207
207
 
208
208
  RCT_EXPORT_METHOD(getApplicationIconBadgeNumber:(RCTResponseSenderBlock)callback) {
209
- if(callback) {
209
+ if(callback) {
210
210
  dispatch_async(dispatch_get_main_queue(), ^{
211
211
  callback(@[ @([UIApplication sharedApplication].applicationIconBadgeNumber) ]);
212
212
  });
213
- }
213
+ }
214
214
  }
215
215
 
216
216
  RCT_EXPORT_METHOD(addToApplicationIconBadgeNumber:(nonnull NSNumber*)badgeNumber) {
@@ -239,6 +239,98 @@ RCT_EXPORT_METHOD(presentInboxUI:(NSDictionary *)styleDictionary) {
239
239
  }
240
240
  }
241
241
 
242
+ RCT_EXPORT_METHOD(messagesWithNoActionPerformedCount:(RCTResponseSenderBlock)callback) {
243
+ [PWInbox messagesWithNoActionPerformedCountWithCompletion:^(NSInteger count, NSError *error) {
244
+ if (callback) {
245
+ callback(@[ @(count) ]);
246
+ }
247
+ }];
248
+ }
249
+
250
+ RCT_EXPORT_METHOD(unreadMessagesCount:(RCTResponseSenderBlock)callback) {
251
+ [PWInbox unreadMessagesCountWithCompletion:^(NSInteger count, NSError *error) {
252
+ if (callback) {
253
+ callback(@[ @(count) ]);
254
+ }
255
+ }];
256
+ }
257
+
258
+ RCT_EXPORT_METHOD(messagesCount:(RCTResponseSenderBlock)callback) {
259
+ [PWInbox messagesCountWithCompletion:^(NSInteger count, NSError *error) {
260
+ if (callback) {
261
+ callback(@[ @(count) ]);
262
+ }
263
+ }];
264
+ }
265
+
266
+ RCT_EXPORT_METHOD(loadMessages:(RCTResponseSenderBlock)success fail:(RCTResponseSenderBlock)fail) {
267
+ [PWInbox loadMessagesWithCompletion:^(NSArray<NSObject<PWInboxMessageProtocol> *> *messages, NSError *error) {
268
+ if (success) {
269
+ NSMutableArray* array = [[NSMutableArray alloc] init];
270
+ for (NSObject<PWInboxMessageProtocol>* message in messages) {
271
+ NSDictionary* dict = [self inboxMessageToDictionary:message];
272
+ [array addObject:dict];
273
+ }
274
+ success( @[ array ]);
275
+ } else if (error != nil && fail != nil) {
276
+ fail(@[ error ]);
277
+ }
278
+ }];
279
+ }
280
+
281
+ RCT_EXPORT_METHOD(readMessage:(NSString*)code) {
282
+ NSArray* arr = [NSArray arrayWithObject:code];
283
+ [PWInbox readMessagesWithCodes:arr];
284
+ }
285
+
286
+ RCT_EXPORT_METHOD(readMessages:(NSArray<NSString*>*)codes) {
287
+ [PWInbox readMessagesWithCodes:codes];
288
+ }
289
+
290
+ RCT_EXPORT_METHOD(deleteMessage:(NSString*)code) {
291
+ NSArray* arr = [NSArray arrayWithObject:code];
292
+ [PWInbox deleteMessagesWithCodes:arr];
293
+ }
294
+
295
+ RCT_EXPORT_METHOD(deleteMessages:(NSArray<NSString*>*)codes) {
296
+ [PWInbox deleteMessagesWithCodes:codes];
297
+ }
298
+
299
+ RCT_EXPORT_METHOD(performAction:(NSString*)code) {
300
+ [PWInbox performActionForMessageWithCode:code];
301
+ }
302
+
303
+ - (NSDictionary*)inboxMessageToDictionary:(NSObject<PWInboxMessageProtocol>*) message {
304
+ NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
305
+ [dictionary setValue:@(message.type) forKey:@"type"];
306
+ [dictionary setValue:[self stringOrEmpty: message.imageUrl] forKey:@"imageUrl"];
307
+ [dictionary setValue:[self stringOrEmpty: message.code] forKey:@"code"];
308
+ [dictionary setValue:[self stringOrEmpty: message.title] forKey:@"title"];
309
+ [dictionary setValue:[self stringOrEmpty: message.message] forKey:@"message"];
310
+ [dictionary setValue:[self stringOrEmpty: [self dateToString:message.sendDate]] forKey:@"sendDate"];
311
+ [dictionary setValue:@(message.isRead) forKey:@"isRead"];
312
+ [dictionary setValue:@(message.isActionPerformed) forKey:@"isActionPerformed"];
313
+
314
+ NSDictionary* actionParams = [NSDictionary dictionaryWithDictionary:message.actionParams];
315
+ NSData* customData = [actionParams valueForKey:@"u"];
316
+ [dictionary setValue:customData forKey:@"customData"];
317
+
318
+ NSDictionary* result = [NSDictionary dictionaryWithDictionary:dictionary];
319
+ return result;
320
+ }
321
+
322
+ - (NSString *)stringOrEmpty:(NSString *)string {
323
+ return string != nil ? string : @"";
324
+ }
325
+
326
+ - (NSString*)dateToString:(NSDate*)date {
327
+ NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
328
+ [formatter setFormatterBehavior:NSDateFormatterBehaviorDefault];
329
+ [formatter setDateStyle:NSDateFormatterFullStyle];
330
+ [formatter setTimeStyle:NSDateFormatterMediumStyle];
331
+ return [formatter stringFromDate:date];
332
+ }
333
+
242
334
  - (PWIInboxStyle *)inboxStyleForDictionary:(NSDictionary *)styleDictionary {
243
335
  PWIInboxStyle *style = [PWIInboxStyle defaultStyle];
244
336
 
@@ -484,11 +576,11 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
484
576
  #pragma mark - PushNotificationDelegate
485
577
 
486
578
  - (void)onDidRegisterForRemoteNotificationsWithDeviceToken:(NSString *)token {
487
- [[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationSuccesEvent withArgs:@[ objectOrNull(token) ]];
579
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationSuccesEvent withArgs:@[ objectOrNull(token) ]];
488
580
  }
489
581
 
490
582
  - (void)onDidFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
491
- [[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationErrorEvent withArgs:@[ objectOrNull([error localizedDescription]) ]];
583
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kRegistrationErrorEvent withArgs:@[ objectOrNull([error localizedDescription]) ]];
492
584
  }
493
585
 
494
586
  - (void)onPushReceived:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
@@ -498,20 +590,20 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
498
590
  }
499
591
 
500
592
  - (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
501
- [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushNotification) ]];
502
-
593
+ [[PWEventDispatcher sharedDispatcher] dispatchEvent:kPushOpenEvent withArgs:@[ objectOrNull(pushNotification) ]];
594
+
503
595
  [self sendJSEvent:kPushOpenJSEvent withArgs:pushNotification];
504
596
  }
505
597
 
506
598
  #pragma mark - RCTEventEmitter
507
599
 
508
600
  - (void)sendJSEvent:(NSString*)event withArgs:(NSDictionary*)args {
509
- // [self sendEventWithName:event body:args];
510
- [self.bridge.eventDispatcher sendDeviceEventWithName:event body:args];
601
+ // [self sendEventWithName:event body:args];
602
+ [self.bridge.eventDispatcher sendDeviceEventWithName:event body:args];
511
603
  }
512
604
 
513
605
  - (NSArray<NSString *> *)supportedEvents {
514
- return @[ kPushOpenJSEvent ];
606
+ return @[ kPushOpenJSEvent ];
515
607
  }
516
608
 
517
609
  @end
@@ -519,7 +611,7 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
519
611
  @implementation UIApplication (InternalPushRuntime)
520
612
 
521
613
  - (BOOL)pushwooshUseRuntimeMagic {
522
- return YES;
614
+ return YES;
523
615
  }
524
616
 
525
617
  // Just keep the launch notification until the module starts and callback functions initalizes
@@ -529,13 +621,13 @@ RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
529
621
  }
530
622
  }
531
623
  - (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
532
- if (onStart) {
533
- gStartPushData = pushNotification;
534
- }
624
+ if (onStart) {
625
+ gStartPushData = pushNotification;
626
+ }
535
627
  }
536
628
 
537
629
  - (NSObject<PushNotificationDelegate> *)getPushwooshDelegate {
538
- return (NSObject<PushNotificationDelegate> *)self;
630
+ return (NSObject<PushNotificationDelegate> *)self;
539
631
  }
540
632
 
541
633
  @end
Binary file