pushwoosh-cordova-plugin 8.3.34 → 8.3.36

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.
@@ -674,6 +674,64 @@ API_AVAILABLE(ios(10.0)) {
674
674
  }];
675
675
  }
676
676
 
677
+ - (void)setEmail:(CDVInvokedUrlCommand *)command {
678
+ NSString *email = command.arguments[0];
679
+ [[Pushwoosh sharedInstance] setEmail:email completion:^(NSError *error) {
680
+ CDVPluginResult *pluginResult;
681
+ if (!error) {
682
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
683
+ } else {
684
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to set email"];
685
+ }
686
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
687
+ }];
688
+ }
689
+
690
+ - (void)setEmails:(CDVInvokedUrlCommand *)command {
691
+ NSArray *emailsArray = command.arguments[0];
692
+ for (NSString *email in emailsArray) {
693
+ [[Pushwoosh sharedInstance] setEmail:email completion:^(NSError *error) {
694
+ CDVPluginResult *pluginResult;
695
+ if (!error) {
696
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
697
+ } else {
698
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to set emails"];
699
+ }
700
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
701
+ }];
702
+ }
703
+ }
704
+
705
+ - (void)setUserEmails:(CDVInvokedUrlCommand *)command {
706
+ NSString *userId = command.arguments[0];
707
+ NSArray *emailsArray = command.arguments[1];
708
+ for (NSString *email in emailsArray) {
709
+ [[Pushwoosh sharedInstance] setUser:userId emails:@[email] completion:^(NSError *error) {
710
+ CDVPluginResult *pluginResult;
711
+ if (!error) {
712
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
713
+ } else {
714
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Failed to set user emails"];
715
+ }
716
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
717
+ }];
718
+ }
719
+ }
720
+
721
+ - (void)registerSMSNumber:(CDVInvokedUrlCommand *)command {
722
+ NSString *phoneNumber = command.arguments[0];
723
+ [[Pushwoosh sharedInstance] registerSmsNumber:phoneNumber];
724
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
725
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
726
+ }
727
+
728
+ - (void)registerWhatsappNumber:(CDVInvokedUrlCommand *)command {
729
+ NSString *phoneNumber = command.arguments[0];
730
+ [[Pushwoosh sharedInstance] registerWhatsappNumber:phoneNumber];
731
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
732
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
733
+ }
734
+
677
735
  - (void)removeAllDeviceData:(CDVInvokedUrlCommand *)command {
678
736
  self.callbackIds[@"removeAllDeviceData"] = command.callbackId;
679
737
 
@@ -87,4 +87,9 @@ export interface PushNotification {
87
87
  setColorLED(color: string, success?: () => void, fail?: () => void): void;
88
88
  getPushHistory(success?: (pushHistory: Object) => void): void;
89
89
  clearPushHistory(callback: () => void): void;
90
+ setEmail(email: string, success?: () => void, fail?: (error: Error|string) => void): void;
91
+ setEmails(emails: string[], success?: () => void, fail?: (error: Error|string) => void): void;
92
+ setUserEmails(userId: string, emails: string[], success?: () => void, fail?: (error: Error|string) => void): void;
93
+ registerSMSNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
94
+ registerWhatsappNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
90
95
  }
@@ -614,6 +614,36 @@ PushNotification.prototype.setCommunicationEnabled = function(enable, success, f
614
614
  exec(success, fail, "PushNotification", "setCommunicationEnabled", [enable]);
615
615
  };
616
616
 
617
+ // Register email associated to the current user.
618
+ // Email should be a string and could not be null or empty.
619
+ PushNotification.prototype.setEmail = function(email, success, fail) {
620
+ exec(success, fail, "PushNotification", "setEmail", [email]);
621
+ };
622
+
623
+ // Register list of emails associated to the current user.
624
+ PushNotification.prototype.setEmails = function(emails, success, fail) {
625
+ exec(success, fail, "PushNotification", "setEmails", [emails]);
626
+ };
627
+
628
+ // Set user identifier and register emails associated to the user.
629
+ // userID can be Facebook ID or any other user ID.
630
+ // This allows data and events to be matched across multiple user devices.
631
+ PushNotification.prototype.setUserEmails = function(userId, emails, success, fail) {
632
+ exec(success, fail, "PushNotification", "setUserEmails", [userId, emails]);
633
+ };
634
+
635
+ // Registers phone number associated to the current user.
636
+ // PhoneNumber should be a string and cannot be null or empty.
637
+ PushNotification.prototype.registerSMSNumber = function(phoneNumber, success, fail) {
638
+ exec(success, fail, "PushNotification", "registerSMSNumber", [phoneNumber]);
639
+ };
640
+
641
+ // Registers Whatsapp number associated to the current user.
642
+ // PhoneNumber should be a string and cannot be null or empty.
643
+ PushNotification.prototype.registerWhatsappNumber = function(phoneNumber, success, fail) {
644
+ exec(success, fail, "PushNotification", "registerWhatsappNumber", [phoneNumber]);
645
+ };
646
+
617
647
  // Removes all device data from Pushwoosh and stops all interactions and communication permanently.
618
648
  PushNotification.prototype.removeAllDeviceData = function(success, fail) {
619
649
  exec(success, fail, "PushNotification", "removeAllDeviceData", []);