pushwoosh-react-native-plugin 6.1.42 → 6.1.43

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/docs/README.md CHANGED
@@ -57,10 +57,7 @@ DeviceEventEmitter.addListener('pushOpened', (e: Event) => {
57
57
  <tr class="even"><td><a href="#setsoundtype">setSoundType(type)</a></td></tr>
58
58
  <tr class="even"><td><a href="#setvibratetype">setVibrateType(type)</a></td></tr>
59
59
  <tr class="even"><td><a href="#presentinboxui">presentInboxUI()</a></td></tr>
60
- <tr class="even"><td><a href="#showgdprconsentui">showGDPRConsentUI()</a></td></tr>
61
- <tr class="even"><td><a href="#showgdprdeletionui">showGDPRDeletionUI()</a></td></tr>
62
60
  <tr class="even"><td><a href="#setcommunicationenabled">setCommunicationEnabled()</a></td></tr>
63
- <tr class="even"><td><a href="#removealldevicedata">removeAllDeviceData()</a></td></tr>
64
61
  <tr class="even"><td><a href="#enableHuaweiPushNotifications">enableHuaweiPushNotifications()</a></td></tr>
65
62
  <tr class="even"><td><a href="#registersmsnumber">registerSMSNumber(phoneNumber)</a></td></tr>
66
63
  <tr class="even"><td><a href="#registerwhatsappnumber">registerWhatsappNumber(phoneNumber)</a></td></tr>
@@ -450,23 +447,6 @@ Opens [Inbox](https://www.pushwoosh.com/docs/message-inbox) screen.
450
447
  Before using Message Inbox, please add node_modules/pushwoosh-react-native-plugin/src/ios/PushwooshInboxBundle.bundle to your project. Or, launch a script 'node node_modules/pushwoosh-react-native-plugin/scripts/add_inbox_ios_resources.js' to do it.
451
448
 
452
449
 
453
- ### showGDPRConsentUI
454
-
455
- ```js
456
- showGDPRConsentUI()
457
- ```
458
- **[android, ios]**
459
- A part of [The GDPR Compliance](https://www.pushwoosh.com/docs/the-gdpr-compliance) solution that shows the GDPR Consent Form, ensuring lawful basis for processing personal data of EU citizens.
460
-
461
-
462
- ### showGDPRDeletionUI
463
-
464
- ```js
465
- showGDPRDeletionUI()
466
- ```
467
- **[android, ios]**
468
- A part of [The GDPR Compliance](https://www.pushwoosh.com/docs/the-gdpr-compliance) solution that shows the GDPR Deletion Form, ensuring means to comply with the right to erasure.
469
-
470
450
 
471
451
  ### setCommunicationEnabled
472
452
 
@@ -477,13 +457,6 @@ setCommunicationEnabled(on: boolean)
477
457
  A binary method enabling/disabling all communication with Pushwoosh. The boolean value is false unsubscribes the device from receiving push notifications and stops in-app messages download. The value true reverses the effect.
478
458
 
479
459
 
480
- ### removeAllDeviceData
481
-
482
- ```js
483
- removeAllDeviceData()
484
- ```
485
- **[android, ios]**
486
- Removes all data about the device. Cannot be undone.
487
460
 
488
461
  ### enableHuaweiPushNotifications
489
462
 
package/index.d.ts CHANGED
@@ -83,14 +83,9 @@ declare module 'pushwoosh-react-native-plugin' {
83
83
  deleteMessages(ids: string[]): void;
84
84
  performAction(id: string): void;
85
85
 
86
- //GDPR methods
87
- showGDPRConsentUI(): void;
88
- showGDPRDeletionUI(): void;
89
- isDeviceDataRemoved(success: (isRemoved: boolean) => void): void;
86
+ //Communication methods
90
87
  isCommunicationEnabled(success: (isEnabled: boolean)=> void): void;
91
- isAvailableGDPR(success: (isAvailable: boolean) => void): void;
92
88
  setCommunicationEnabled(enabled: boolean, success?: () => void, fail?: (error: Error) => void): void;
93
- removeAllDeviceData(success?: () => void, fail?: (error: Error) => void): void;
94
89
 
95
90
  }
96
91
 
package/index.js CHANGED
@@ -590,29 +590,12 @@ class PushNotification {
590
590
  PushwooshModule.performAction(id);
591
591
  }
592
592
 
593
- // Show inApp for change setting Enable/disable all communication with Pushwoosh
594
- showGDPRConsentUI(){
595
- PushwooshModule.showGDPRConsentUI();
596
- }
597
-
598
- // Show inApp for all device data from Pushwoosh and stops all interactions and communication permanently.
599
- showGDPRDeletionUI(){
600
- PushwooshModule.showGDPRDeletionUI();
601
- }
602
-
603
- isDeviceDataRemoved(success: Function){
604
- PushwooshModule.isDeviceDataRemoved(success);
605
- }
606
593
 
607
594
  // Return flag is enable communication with server
608
595
  isCommunicationEnabled(success: Function){
609
596
  PushwooshModule.isCommunicationEnabled(success);
610
597
  }
611
598
 
612
- // Return flag is enabled GDPR on server
613
- isAvailableGDPR(success: Function){
614
- PushwooshModule.isAvailableGDPR(success);
615
- }
616
599
 
617
600
  // Enable/disable all communication with Pushwoosh. Enabled by default.
618
601
  setCommunicationEnabled(enable: boolean, success: ?Function, fail: ?Function) {
@@ -625,16 +608,6 @@ class PushNotification {
625
608
  PushwooshModule.setCommunicationEnabled(enable, success, fail);
626
609
  }
627
610
 
628
- // Removes all device data from Pushwoosh and stops all interactions and communication permanently.
629
- removeAllDeviceData( success: ?Function, fail: ?Function) {
630
- if (!success) {
631
- success = function() {};
632
- }
633
- if (!fail) {
634
- fail = function(error) {};
635
- }
636
- PushwooshModule.removeAllDeviceData(success, fail);
637
- }
638
611
 
639
612
  // Set notification icon background color
640
613
  setNotificationIconBackgroundColor(color: string) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwoosh-react-native-plugin",
3
- "version": "6.1.42",
3
+ "version": "6.1.43",
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.42"
3
+ s.version = "6.1.43"
4
4
  s.summary = "React Native Pushwoosh Push Notifications module"
5
5
  s.requires_arc = true
6
6
  s.author = 'Pushwoosh'
@@ -15,6 +15,6 @@ Pod::Spec.new do |s|
15
15
  s.static_framework = true
16
16
 
17
17
  s.dependency 'React'
18
- s.dependency 'PushwooshXCFramework', '6.10.4'
18
+ s.dependency 'PushwooshXCFramework', '6.10.5'
19
19
  s.dependency 'PushwooshInboxUIXCFramework'
20
20
  end
@@ -18,7 +18,6 @@ import com.facebook.react.bridge.ReactMethod;
18
18
  import com.facebook.react.bridge.ReadableArray;
19
19
  import com.facebook.react.bridge.ReadableMap;
20
20
  import com.facebook.react.bridge.WritableNativeArray;
21
- import com.pushwoosh.GDPRManager;
22
21
  import com.pushwoosh.Pushwoosh;
23
22
  import com.pushwoosh.RegisterForPushNotificationsResultData;
24
23
  import com.pushwoosh.badge.PushwooshBadge;
@@ -30,7 +29,7 @@ import com.pushwoosh.exception.SetUserIdException;
30
29
  import com.pushwoosh.exception.RegisterForPushNotificationsException;
31
30
  import com.pushwoosh.exception.UnregisterForPushNotificationException;
32
31
  import com.pushwoosh.function.Result;
33
- import com.pushwoosh.inapp.PushwooshInApp;
32
+ import com.pushwoosh.inapp.InAppManager;
34
33
  import com.pushwoosh.inbox.PushwooshInbox;
35
34
  import com.pushwoosh.inbox.data.InboxMessage;
36
35
  import com.pushwoosh.inbox.exception.InboxMessagesException;
@@ -306,7 +305,7 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
306
305
 
307
306
  @ReactMethod
308
307
  public void postEvent(String event, ReadableMap attributes) {
309
- PushwooshInApp.getInstance().postEvent(event, ConversionUtil.convertToTagsBundle(attributes));
308
+ InAppManager.getInstance().postEvent(event, ConversionUtil.convertToTagsBundle(attributes));
310
309
  }
311
310
 
312
311
  @ReactMethod
@@ -498,67 +497,28 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
498
497
  PushwooshInbox.performAction(id);
499
498
  }
500
499
 
501
- @ReactMethod
502
- public void showGDPRConsentUI(){
503
- GDPRManager.getInstance().showGDPRConsentUI();
504
- }
505
-
506
- @ReactMethod
507
- public void showGDPRDeletionUI(){
508
- GDPRManager.getInstance().showGDPRDeletionUI();
509
- }
510
-
511
- @ReactMethod
512
- public void isDeviceDataRemoved(final Callback success){
513
- success.invoke(GDPRManager.getInstance().isDeviceDataRemoved());
514
- }
515
-
516
500
  @ReactMethod
517
501
  public void isCommunicationEnabled(final Callback success){
518
- success.invoke(GDPRManager.getInstance().isCommunicationEnabled());
519
- }
520
-
521
- @ReactMethod
522
- public void isAvailableGDPR(final Callback success){
523
- success.invoke(GDPRManager.getInstance().isAvailable());
502
+ success.invoke(Pushwoosh.getInstance().isServerCommunicationAllowed());
524
503
  }
525
504
 
526
505
  @ReactMethod
527
506
  public void setCommunicationEnabled(boolean enable, final Callback success, final Callback error) {
528
- GDPRManager.getInstance().setCommunicationEnabled(enable, new com.pushwoosh.function.Callback<Void, PushwooshException>() {
529
- @Override
530
- public void process(Result<Void, PushwooshException> result) {
531
- if (result.isSuccess()) {
532
- if (success != null) {
533
- success.invoke(result.getData());
534
- }
535
- } else if (result.getException() != null) {
536
- if (error != null) {
537
- error.invoke(result.getException().getLocalizedMessage());
538
- }
539
- }
507
+ try {
508
+ if (enable) {
509
+ Pushwoosh.getInstance().startServerCommunication();
510
+ } else {
511
+ Pushwoosh.getInstance().stopServerCommunication();
540
512
  }
541
- });
542
- }
543
-
544
- @ReactMethod
545
- public void removeAllDeviceData(final Callback success, final Callback error) {
546
- GDPRManager.getInstance().removeAllDeviceData(new com.pushwoosh.function.Callback<Void, PushwooshException>() {
547
- @Override
548
- public void process(Result<Void, PushwooshException> result) {
549
- if (result.isSuccess()) {
550
- if (success != null) {
551
- success.invoke(result.getData());
552
- }
553
- } else if (result.getException() != null) {
554
- if (error != null) {
555
- error.invoke(result.getException().getLocalizedMessage());
556
- }
557
- }
513
+ success.invoke();
514
+ } catch (Exception e) {
515
+ if (error != null) {
516
+ error.invoke(e.getMessage());
558
517
  }
559
- });
518
+ }
560
519
  }
561
520
 
521
+
562
522
  @ReactMethod
563
523
  public void setLanguage(String language){
564
524
  Pushwoosh.getInstance().setLanguage(language);
@@ -14,14 +14,12 @@
14
14
  #import <PushwooshFramework/PushNotificationManager.h>
15
15
  #import <PushwooshFramework/PWInAppManager.h>
16
16
  #import <PushwooshInboxUI/PushwooshInboxUI.h>
17
- #import <PushwooshFramework/PWGDPRManager.h>
18
17
  #import <PushwooshFramework/PWInlineInAppView.h>
19
18
  #import <PushwooshFramework/PWInbox.h>
20
19
  #else
21
20
  #import "PushNotificationManager.h"
22
21
  #import "PWInAppManager.h"
23
22
  #import "PushwooshInboxUI.h"
24
- #import "PWGDPRManager.h"
25
23
  #import "PWInlineInAppView.h"
26
24
  #import "PWInbox.h"
27
25
  #endif
@@ -19,6 +19,10 @@
19
19
 
20
20
  #define kPushwooshPluginImplementationInfoPlistKey @"Pushwoosh_PLUGIN_NOTIFICATION_HANDLER"
21
21
 
22
+ #define PW_COMMUNICATION_ENABLED_KEY @"PushwooshCommunicationEnabled"
23
+ #define PW_COMMUNICATION_ENABLED_PLIST_KEY @"Pushwoosh_ALLOW_SERVER_COMMUNICATION"
24
+
25
+
22
26
  static id objectOrNull(id object) {
23
27
  if (object) {
24
28
  return object;
@@ -773,54 +777,46 @@ API_AVAILABLE(ios(10.0)) {
773
777
  return controller;
774
778
  }
775
779
 
776
- RCT_EXPORT_METHOD(showGDPRConsentUI) {
777
- [[PWGDPRManager sharedManager] showGDPRConsentUI];
778
- }
779
-
780
- RCT_EXPORT_METHOD(showGDPRDeletionUI) {
781
- [[PWGDPRManager sharedManager] showGDPRDeletionUI];
782
- }
783
-
784
- RCT_EXPORT_METHOD(isDeviceDataRemoved:(RCTResponseSenderBlock)callback) {
785
- callback(@[@([PWGDPRManager sharedManager].isDeviceDataRemoved)]);
786
- }
787
-
788
780
  RCT_EXPORT_METHOD(isCommunicationEnabled:(RCTResponseSenderBlock)callback) {
789
- callback(@[@([PWGDPRManager sharedManager].isCommunicationEnabled)]);
790
- }
781
+ BOOL isCommunicationEnabled = [self getCommunicationEnabledState];
791
782
 
792
- RCT_EXPORT_METHOD(isAvailableGDPR:(RCTResponseSenderBlock)callback) {
793
- callback(@[@([PWGDPRManager sharedManager].isAvailable)]);
783
+ callback(@[@(isCommunicationEnabled)]);
794
784
  }
795
785
 
796
786
  RCT_EXPORT_METHOD(setCommunicationEnabled:(BOOL)enabled success:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
797
- [[PWGDPRManager sharedManager] setCommunicationEnabled:enabled completion:^(NSError *error) {
798
- if (error) {
799
- if (errorCallback) {
800
- errorCallback(@[error.localizedDescription]);
801
- }
802
- } else {
803
- if (successCallback) {
804
- successCallback(@[]);
805
- }
806
- }
807
- }];
787
+ [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:PW_COMMUNICATION_ENABLED_KEY];
788
+
789
+ if (enabled) {
790
+ [[Pushwoosh sharedInstance] startServerCommunication];
791
+ } else {
792
+ [[Pushwoosh sharedInstance] stopServerCommunication];
793
+ }
794
+
795
+
796
+ successCallback(@[]);
808
797
  }
809
798
 
810
- RCT_EXPORT_METHOD(removeAllDeviceData:(RCTResponseSenderBlock)successCallback error:(RCTResponseSenderBlock)errorCallback) {
811
- [[PWGDPRManager sharedManager] removeAllDeviceDataWithCompletion:^(NSError *error) {
812
- if (error) {
813
- if (errorCallback) {
814
- errorCallback(@[error.localizedDescription]);
815
- }
816
- } else {
817
- if (successCallback) {
818
- successCallback(@[]);
819
- }
799
+ - (BOOL)getCommunicationEnabledState {
800
+ NSBundle *bundle = [NSBundle mainBundle];
801
+ NSObject *plistValue = [bundle objectForInfoDictionaryKey:PW_COMMUNICATION_ENABLED_PLIST_KEY];
802
+
803
+ if (plistValue != nil) {
804
+ if ([plistValue isKindOfClass:[NSNumber class]]) {
805
+ return [(NSNumber *)plistValue boolValue];
806
+ } else if ([plistValue isKindOfClass:[NSString class]]) {
807
+ NSString *stringValue = [(NSString *)plistValue lowercaseString];
808
+ return [stringValue isEqualToString:@"true"] || [stringValue isEqualToString:@"yes"] || [stringValue isEqualToString:@"1"];
820
809
  }
821
- }];
810
+ }
811
+
812
+ if ([[NSUserDefaults standardUserDefaults] objectForKey:PW_COMMUNICATION_ENABLED_KEY] != nil) {
813
+ return [[NSUserDefaults standardUserDefaults] boolForKey:PW_COMMUNICATION_ENABLED_KEY];
814
+ }
815
+
816
+ return YES;
822
817
  }
823
818
 
819
+
824
820
  RCT_EXPORT_METHOD(createLocalNotification:(NSDictionary *)params){
825
821
  NSString *body = params[@"msg"];
826
822
  NSUInteger delay = [params[@"seconds"] unsignedIntegerValue];