pushwoosh-cordova-plugin 8.3.39 → 8.3.41

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.
@@ -6,7 +6,7 @@
6
6
  //
7
7
  // Pushwoosh Push Notifications Plugin for Cordova iOS
8
8
  // www.pushwoosh.com
9
- // (c) Pushwoosh 2012
9
+ // (c) Pushwoosh 2025
10
10
  //
11
11
  // MIT Licensed
12
12
 
@@ -20,6 +20,16 @@
20
20
  #import "PWBackward.h"
21
21
 
22
22
  #import "AppDelegate.h"
23
+ #import <UserNotifications/UserNotifications.h>
24
+
25
+ #if __has_include(<PushwooshVoIP/PushwooshVoIP.h>)
26
+ #import <PushwooshVoIP/PushwooshVoIP.h>
27
+ #import <CallKit/CallKit.h>
28
+ #import <AVFoundation/AVFoundation.h>
29
+ #define PW_VOIP_ENABLED 1
30
+ #else
31
+ #define PW_VOIP_ENABLED 0
32
+ #endif
23
33
 
24
34
  #import <UserNotifications/UserNotifications.h>
25
35
 
@@ -28,6 +38,12 @@
28
38
 
29
39
  #define WRITEJS(VAL) [NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", VAL]
30
40
 
41
+ NSMutableDictionary *callbackIds;
42
+ NSDictionary* pendingCallFromRecents;
43
+ BOOL monitorAudioRouteChange = NO;
44
+ BOOL initSupportsVideo = NO;
45
+ NSString *ringtoneSound;
46
+ NSInteger handleType;
31
47
 
32
48
  @interface PWCommonJSBridge: NSObject <PWJavaScriptInterface>
33
49
 
@@ -45,8 +61,16 @@
45
61
 
46
62
  @end
47
63
 
64
+ #if PW_VOIP_ENABLED
65
+ @interface PushNotification() <PWMessagingDelegate, UIApplicationDelegate, PWVoIPCallDelegate>
66
+ #else
48
67
  @interface PushNotification() <PWMessagingDelegate, UIApplicationDelegate>
68
+ #endif
49
69
 
70
+ #if PW_VOIP_ENABLED
71
+ @property (nonatomic, strong) CXCallController *callController;
72
+ @property (nonatomic, strong) CXProvider *provider;
73
+ #endif
50
74
  @property (nonatomic, retain) NSMutableDictionary *callbackIds;
51
75
  @property (nonatomic, retain) PushNotificationManager *pushManager;
52
76
  @property (nonatomic, retain) Pushwoosh *pushwoosh;
@@ -96,6 +120,25 @@ API_AVAILABLE(ios(10))
96
120
  - (void)pluginInitialize {
97
121
  [super pluginInitialize];
98
122
  pw_PushNotificationPlugin = self;
123
+ #if PW_VOIP_ENABLED
124
+ callbackIds = [[NSMutableDictionary alloc] initWithCapacity:5];
125
+ [callbackIds setObject:[NSMutableArray array] forKey:@"initializeVoIPParameters"];
126
+ [callbackIds setObject:[NSMutableArray array] forKey:@"answer"];
127
+ [callbackIds setObject:[NSMutableArray array] forKey:@"endCall"];
128
+ [callbackIds setObject:[NSMutableArray array] forKey:@"hangup"];
129
+ [callbackIds setObject:[NSMutableArray array] forKey:@"reject"];
130
+ [callbackIds setObject:[NSMutableArray array] forKey:@"muted"];
131
+ [callbackIds setObject:[NSMutableArray array] forKey:@"held"];
132
+ [callbackIds setObject:[NSMutableArray array] forKey:@"voipPushPayload"];
133
+ [callbackIds setObject:[NSMutableArray array] forKey:@"incomingCallSuccess"];
134
+ [callbackIds setObject:[NSMutableArray array] forKey:@"incomingCallFailure"];
135
+ [callbackIds setObject:[NSMutableArray array] forKey:@"speakerOn"];
136
+ [callbackIds setObject:[NSMutableArray array] forKey:@"speakerOff"];
137
+ [callbackIds setObject:[NSMutableArray array] forKey:@"playDTMF"];
138
+
139
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCallFromRecents:) name:@"RecentsCallNotification" object:nil];
140
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioRouteChange:) name:AVAudioSessionRouteChangeNotification object:nil];
141
+ #endif
99
142
  }
100
143
 
101
144
  - (NSMutableDictionary *)callbackIds {
@@ -578,6 +621,359 @@ API_AVAILABLE(ios(10.0)) {
578
621
  }
579
622
  }
580
623
 
624
+ #if PW_VOIP_ENABLED
625
+ // MARK: - Voip settings
626
+ - (void)requestCallPermission:(CDVInvokedUrlCommand *)command {
627
+ //stub, android only
628
+ }
629
+
630
+ - (void)setVoipAppCode:(CDVInvokedUrlCommand *)command {
631
+ NSString *voipAppCode = command.arguments[0];
632
+ [PushwooshVoIPImplementation setPushwooshVoIPAppId:voipAppCode];
633
+ }
634
+
635
+ // MARK: - VoIP, CallKit callbacks
636
+ - (void)receiveCallFromRecents:(NSNotification *) notification {
637
+ NSString* callID = notification.object[@"callId"];
638
+ NSString* callName = notification.object[@"callName"];
639
+ NSUUID *callUUID = [[NSUUID alloc] init];
640
+ CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:callID];
641
+ CXStartCallAction *startCallAction = [[CXStartCallAction alloc] initWithCallUUID:callUUID handle:handle];
642
+ startCallAction.video = [notification.object[@"isVideo"] boolValue] ? YES : NO;
643
+ startCallAction.contactIdentifier = callName;
644
+ CXTransaction *transaction = [[CXTransaction alloc] initWithAction:startCallAction];
645
+ [self.callController requestTransaction:transaction completion:^(NSError * _Nullable error) {
646
+ if (error == nil) {
647
+ } else {
648
+ NSLog(@"%@",[error localizedDescription]);
649
+ }
650
+ }];
651
+ }
652
+
653
+ - (void)handleAudioRouteChange:(NSNotification *) notification {
654
+ if(monitorAudioRouteChange) {
655
+ NSNumber* reasonValue = notification.userInfo[@"AVAudioSessionRouteChangeReasonKey"];
656
+ AVAudioSessionRouteDescription* previousRouteKey = notification.userInfo[@"AVAudioSessionRouteChangePreviousRouteKey"];
657
+ NSArray* outputs = [previousRouteKey outputs];
658
+ if([outputs count] > 0) {
659
+ AVAudioSessionPortDescription *output = outputs[0];
660
+ if(![output.portType isEqual: @"Speaker"] && [reasonValue isEqual:@4]) {
661
+ for (id callbackId in callbackIds[@"speakerOn"]) {
662
+ CDVPluginResult* pluginResult = nil;
663
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"speakerOn event called successfully"];
664
+ [pluginResult setKeepCallbackAsBool:YES];
665
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
666
+ }
667
+ } else if([output.portType isEqual: @"Speaker"] && [reasonValue isEqual:@3]) {
668
+ for (id callbackId in callbackIds[@"speakerOff"]) {
669
+ CDVPluginResult* pluginResult = nil;
670
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"speakerOff event called successfully"];
671
+ [pluginResult setKeepCallbackAsBool:YES];
672
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
673
+ }
674
+ }
675
+ }
676
+ }
677
+ }
678
+
679
+ - (void)returnedCallController:(CXCallController *)controller {
680
+ self.callController = controller;
681
+ }
682
+
683
+ - (void)returnedProvider:(CXProvider *)provider {
684
+ self.provider = provider;
685
+ }
686
+
687
+ // MARK: - Initialize CallKit Parameters
688
+ - (void)initializeVoIPParameters:(CDVInvokedUrlCommand *)command {
689
+ CDVPluginResult* pluginResult = nil;
690
+
691
+ NSNumber *supportsVideoNumber = [command.arguments objectAtIndex:0];
692
+ NSString *ringtoneSound = [command.arguments objectAtIndex:1];
693
+ NSNumber *handleTypesNumber = [command.arguments objectAtIndex:2];
694
+
695
+ if ([supportsVideoNumber isKindOfClass:[NSNumber class]] &&
696
+ [ringtoneSound isKindOfClass:[NSString class]] && ringtoneSound.length > 0 &&
697
+ [handleTypesNumber isKindOfClass:[NSNumber class]]) {
698
+
699
+ BOOL supportsVideo = [supportsVideoNumber boolValue];
700
+ NSInteger handleTypes = [handleTypesNumber integerValue];
701
+
702
+ PushwooshVoIPImplementation.delegate = self;
703
+ [PushwooshVoIPImplementation initializeVoIP:supportsVideo
704
+ ringtoneSound:ringtoneSound
705
+ handleTypes:handleTypes];
706
+
707
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"VoIP Parameters Initialized"];
708
+ } else {
709
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid Parameters"];
710
+ }
711
+
712
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
713
+ }
714
+
715
+ // MARK: - Incoming Call Payload
716
+ - (void)voipDidReceiveIncomingCallWithPayload:(PWVoIPMessage *)payload {
717
+ for (id callbackId in callbackIds[@"voipPushPayload"]) {
718
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self handleVoIPMessage:payload]];
719
+ [pluginResult setKeepCallbackAsBool:YES];
720
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
721
+ }
722
+ }
723
+
724
+ // MARK: - Incoming Call Success
725
+ - (void)voipDidReportIncomingCallSuccessfullyWithVoipMessage:(PWVoIPMessage *)voipMessage {
726
+ for (id callbackId in callbackIds[@"incomingCallSuccess"]) {
727
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self handleVoIPMessage:voipMessage]];
728
+ [pluginResult setKeepCallbackAsBool:YES];
729
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
730
+ }
731
+ }
732
+
733
+ // MARK: - Incoming Call Failure
734
+ - (void)voipDidFailToReportIncomingCallWithError:(NSError *)error {
735
+ for (id callbackId in callbackIds[@"incomingCallFailure"]) {
736
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[NSString stringWithFormat:@"Error incoming call: %@", error.localizedDescription]];
737
+ [pluginResult setKeepCallbackAsBool:YES];
738
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
739
+ }
740
+ }
741
+
742
+ - (void)pwProviderDidBegin:(CXProvider *)provider {}
743
+
744
+ - (void)pwProviderDidReset:(CXProvider *)provider {}
745
+
746
+ // MARK: - Register event func
747
+ - (void)registerEvent:(CDVInvokedUrlCommand*)command {
748
+ NSString* eventName = [command.arguments objectAtIndex:0];
749
+ if(callbackIds[eventName] != nil) {
750
+ [callbackIds[eventName] addObject:command.callbackId];
751
+ }
752
+
753
+ if (pendingCallFromRecents && [eventName isEqual:@"sendCall"]) {
754
+ NSDictionary *callData = pendingCallFromRecents;
755
+ CDVPluginResult* pluginResult = nil;
756
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:callData];
757
+ [pluginResult setKeepCallbackAsBool:YES];
758
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
759
+ }
760
+ }
761
+
762
+ // MARK: - Send Call
763
+ - (void)sendCall:(CDVInvokedUrlCommand*)command {
764
+ BOOL hasId = ![[command.arguments objectAtIndex:1] isEqual:[NSNull null]];
765
+ NSString* callName = [command.arguments objectAtIndex:0];
766
+ NSString* callId = hasId?[command.arguments objectAtIndex:1]:callName;
767
+ NSUUID *callUUID = [[NSUUID alloc] init];
768
+
769
+ if (callName != nil && [callName length] > 0) {
770
+ CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:callId];
771
+ CXStartCallAction *startCallAction = [[CXStartCallAction alloc] initWithCallUUID:callUUID handle:handle];
772
+ startCallAction.contactIdentifier = callName;
773
+ startCallAction.video = YES;
774
+ CXTransaction *transaction = [[CXTransaction alloc] initWithAction:startCallAction];
775
+ [self.callController requestTransaction:transaction completion:^(NSError * _Nullable error) {
776
+ if (error == nil) {
777
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Outgoing call successful"] callbackId:command.callbackId];
778
+ } else {
779
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]] callbackId:command.callbackId];
780
+ }
781
+ }];
782
+ } else {
783
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"The caller id can't be empty"] callbackId:command.callbackId];
784
+ }
785
+ }
786
+
787
+ // MARK: - Connect Call
788
+ - (void)connectCall:(CDVInvokedUrlCommand*)command {
789
+ CDVPluginResult* pluginResult = nil;
790
+ NSArray<CXCall *> *calls = self.callController.callObserver.calls;
791
+
792
+ if([calls count] == 1) {
793
+ [self.provider reportOutgoingCallWithUUID:calls[0].UUID connectedAtDate:nil];
794
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Call connected successfully"];
795
+ } else {
796
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No call exists for you to connect"];
797
+ }
798
+
799
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
800
+ }
801
+
802
+ // MARK: - End Call
803
+ - (void)endCall:(CDVInvokedUrlCommand*)command {
804
+ CDVPluginResult* pluginResult = nil;
805
+ NSArray<CXCall *> *calls = self.callController.callObserver.calls;
806
+
807
+ if([calls count] == 1) {
808
+ CXEndCallAction *endCallAction = [[CXEndCallAction alloc] initWithCallUUID:calls[0].UUID];
809
+ CXTransaction *transaction = [[CXTransaction alloc] initWithAction:endCallAction];
810
+ [self.callController requestTransaction:transaction completion:^(NSError * _Nullable error) {
811
+ if (error == nil) {
812
+ } else {
813
+ NSLog(@"%@",[error localizedDescription]);
814
+ }
815
+ }];
816
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Call ended successfully"];
817
+ } else {
818
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No call exists for you to connect"];
819
+ }
820
+
821
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
822
+ }
823
+
824
+ // MARK: - Start Outgoing Call
825
+ - (void)startCall:(CXProvider *)provider perform:(CXStartCallAction *)action {
826
+ [self setupAudioSession];
827
+ CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
828
+ callUpdate.remoteHandle = action.handle;
829
+ callUpdate.hasVideo = action.video;
830
+ callUpdate.localizedCallerName = action.contactIdentifier;
831
+ callUpdate.supportsGrouping = NO;
832
+ callUpdate.supportsUngrouping = NO;
833
+ callUpdate.supportsHolding = NO;
834
+
835
+ [self.provider reportCallWithUUID:action.callUUID updated:callUpdate];
836
+ [action fulfill];
837
+ NSDictionary *callData = @{@"callName":action.contactIdentifier,
838
+ @"callId": action.handle.value,
839
+ @"isVideo": action.video ? @YES : @NO,
840
+ @"message": @"sendCall event called successfully"};
841
+ for (id callbackId in callbackIds[@"sendCall"]) {
842
+ CDVPluginResult* pluginResult = nil;
843
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:callData];
844
+ [pluginResult setKeepCallbackAsBool:YES];
845
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
846
+ }
847
+
848
+ if ([callbackIds[@"sendCall"] count] == 0) {
849
+ pendingCallFromRecents = callData;
850
+ }
851
+ }
852
+
853
+ // MARK: - Answer Call
854
+ - (void)answerCall:(CXProvider *)provider perform:(CXAnswerCallAction *)action voipMessage:(PWVoIPMessage *)voipMessage {
855
+ [self setupAudioSession];
856
+ [action fulfill];
857
+
858
+ for (id callbackId in callbackIds[@"answer"]) {
859
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self handleVoIPMessage:voipMessage]];
860
+ [pluginResult setKeepCallbackAsBool:YES];
861
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
862
+ }
863
+ }
864
+
865
+ // MARK: - End Call
866
+ - (void)endCall:(CXProvider *)provider perform:(CXEndCallAction *)action voipMessage:(PWVoIPMessage *)voipMessage {
867
+ NSArray<CXCall *> *calls = self.callController.callObserver.calls;
868
+ if([calls count] == 1) {
869
+ if(calls[0].hasConnected) {
870
+ for (id callbackId in callbackIds[@"hangup"]) {
871
+ CDVPluginResult* pluginResult = nil;
872
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self handleVoIPMessage:voipMessage]];
873
+ [pluginResult setKeepCallbackAsBool:YES];
874
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
875
+ }
876
+ } else {
877
+ for (id callbackId in callbackIds[@"reject"]) {
878
+ CDVPluginResult* pluginResult = nil;
879
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self handleVoIPMessage:voipMessage]];
880
+ [pluginResult setKeepCallbackAsBool:YES];
881
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
882
+ }
883
+ }
884
+ }
885
+ monitorAudioRouteChange = NO;
886
+ [action fulfill];
887
+ }
888
+
889
+ // MARK: - Muted Call
890
+ - (void)mutedCall:(CXProvider *)provider perform:(CXSetMutedCallAction *)action {
891
+ BOOL isMuted = action.muted;
892
+ for (id callbackId in callbackIds[@"muted"]) {
893
+ CDVPluginResult* pluginResult = nil;
894
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:isMuted ? @"true" : @"false"];
895
+ [pluginResult setKeepCallbackAsBool:YES];
896
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
897
+ }
898
+ [action fulfill];
899
+ }
900
+
901
+ // MARK: - Audio Session Activate (Inner)
902
+ - (void)activatedAudioSession:(CXProvider *)provider didActivate:(AVAudioSession *)audioSession {
903
+ monitorAudioRouteChange = YES;
904
+ }
905
+
906
+ // MARK: - Audio Session Deactivate (Inner)
907
+ - (void)deactivatedAudioSession:(CXProvider *)provider didDeactivate:(AVAudioSession *)audioSession {
908
+ NSLog(@"Audio session deactivated");
909
+ }
910
+
911
+ // MARK: - On Hold Call
912
+ - (void)heldCall:(CXProvider *)provider perform:(CXSetHeldCallAction *)action {
913
+ BOOL isOnHold = action.isOnHold;
914
+ for (id callbackId in callbackIds[@"held"]) {
915
+ CDVPluginResult* pluginResult = nil;
916
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:isOnHold ? @"true" : @"false"];
917
+ [pluginResult setKeepCallbackAsBool:YES];
918
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
919
+ }
920
+
921
+ [action fulfill];
922
+ }
923
+
924
+ // MARK: - Play DTMF
925
+ - (void)playDTMF:(CXProvider *)provider perform:(CXPlayDTMFCallAction *)action {
926
+ NSString *digits = action.digits;
927
+ [action fulfill];
928
+
929
+ for (id callbackId in callbackIds[@"playDTMF"]) {
930
+ CDVPluginResult* pluginResult = nil;
931
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:digits];
932
+ [pluginResult setKeepCallbackAsBool:YES];
933
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
934
+ }
935
+ }
936
+
937
+ - (void)setupAudioSession {
938
+ AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
939
+ NSError *error = nil;
940
+
941
+ if (![sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]) {
942
+ NSLog(@"Error setting category: %@", error.localizedDescription);
943
+ return;
944
+ }
945
+
946
+ if (![sessionInstance setMode:AVAudioSessionModeVoiceChat error:&error]) {
947
+ NSLog(@"Error setting mode: %@", error.localizedDescription);
948
+ return;
949
+ }
950
+
951
+ NSTimeInterval bufferDuration = 0.005;
952
+ if (![sessionInstance setPreferredIOBufferDuration:bufferDuration error:&error]) {
953
+ NSLog(@"Error setting buffer duration: %@", error.localizedDescription);
954
+ return;
955
+ }
956
+
957
+ if (![sessionInstance setPreferredSampleRate:44100 error:&error]) {
958
+ NSLog(@"Error setting sample rate: %@", error.localizedDescription);
959
+ return;
960
+ }
961
+
962
+ NSLog(@"Audio session configured successfully");
963
+ }
964
+
965
+ - (NSDictionary *)handleVoIPMessage:(PWVoIPMessage *)voipMessage {
966
+ if (!voipMessage) return @{};
967
+ NSMutableDictionary *payload = [[NSMutableDictionary alloc] init];
968
+ [payload addEntriesFromDictionary:@{@"rawPayload": voipMessage.rawPayload}];
969
+ [payload addEntriesFromDictionary:@{@"uuid": voipMessage.uuid}];
970
+ [payload addEntriesFromDictionary:@{@"callerName": voipMessage.callerName}];
971
+ [payload addEntriesFromDictionary:@{@"handleType": @(voipMessage.handleType)}];
972
+ [payload addEntriesFromDictionary:@{@"hasVideo": @(voipMessage.hasVideo)}];
973
+ return payload;
974
+ }
975
+ #endif
976
+
581
977
  - (void)getRemoteNotificationStatus:(CDVInvokedUrlCommand *)command {
582
978
  NSMutableDictionary *results = [PushNotificationManager getRemoteNotificationStatus];
583
979
 
@@ -647,20 +1043,6 @@ API_AVAILABLE(ios(10.0)) {
647
1043
  [[PWInAppManager sharedManager] addJavascriptInterface:bridge withName:name];
648
1044
  }
649
1045
 
650
- - (void)showGDPRConsentUI:(CDVInvokedUrlCommand *)command {
651
- [[PWGDPRManager sharedManager] showGDPRConsentUI];
652
-
653
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
654
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
655
- }
656
-
657
- - (void)showGDPRDeletionUI:(CDVInvokedUrlCommand *)command {
658
- [[PWGDPRManager sharedManager] showGDPRDeletionUI];
659
-
660
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
661
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
662
- }
663
-
664
1046
  - (void)setCommunicationEnabled:(CDVInvokedUrlCommand *)command {
665
1047
  self.callbackIds[@"setCommunicationEnabled"] = command.callbackId;
666
1048
 
@@ -737,35 +1119,11 @@ API_AVAILABLE(ios(10.0)) {
737
1119
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
738
1120
  }
739
1121
 
740
- - (void)removeAllDeviceData:(CDVInvokedUrlCommand *)command {
741
- self.callbackIds[@"removeAllDeviceData"] = command.callbackId;
742
-
743
- [[PWGDPRManager sharedManager] removeAllDeviceDataWithCompletion:^(NSError *error) {
744
- if (!error) {
745
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
746
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"removeAllDeviceData"]];
747
- } else {
748
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.localizedDescription];
749
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackIds[@"removeAllDeviceData"]];
750
- }
751
- }];
752
- }
753
-
754
1122
  - (void)isCommunicationEnabled:(CDVInvokedUrlCommand *)command {
755
1123
  CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:[[PWGDPRManager sharedManager] isCommunicationEnabled]];
756
1124
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
757
1125
  }
758
1126
 
759
- - (void)isDeviceDataRemoved:(CDVInvokedUrlCommand *)command {
760
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:[[PWGDPRManager sharedManager] isDeviceDataRemoved]];
761
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
762
- }
763
-
764
- - (void)isAvailableGDPR:(CDVInvokedUrlCommand *)command {
765
- CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:[[PWGDPRManager sharedManager] isAvailable]];
766
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
767
- }
768
-
769
1127
  - (void)enableHuaweiPushNotifications:(CDVInvokedUrlCommand *)command {
770
1128
  // Stub
771
1129
 
@@ -1,4 +1,4 @@
1
- interface PushwooshConfig {
1
+ interface PushwooshConfig {
2
2
  projectid: string,
3
3
  appid: string,
4
4
  serviceName?: string
@@ -72,13 +72,8 @@ export interface PushNotification {
72
72
  readMessage(id: string): void;
73
73
  deleteMessage(id: string): void;
74
74
  performAction(id: string): void;
75
- showGDPRConsentUI(): void;
76
- showGDPRDeletionUI(): void;
77
75
  setCommunicationEnabled(enable: boolean, success?: () => void, fail?: (callback: Error|string) => void): void;
78
- removeAllDeviceData(success?: () => void, fail?: (callback: Error|string) => void): void;
79
76
  isCommunicationEnabled(success: (enabled: boolean) => void): void;
80
- isDeviceDataRemoved(success: (removed: boolean) => void): void;
81
- isAvailableGDPR(success: (isAvailable: boolean) => void): void;
82
77
  enableHuaweiPushNotifications(): void;
83
78
  setSoundType(type: string, success?: () => void, fail?: () => void): void;
84
79
  setVibrateType(type: string, success?: () => void, fail?: () => void): void;
@@ -93,4 +88,13 @@ export interface PushNotification {
93
88
  registerSMSNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
94
89
  registerWhatsappNumber(phoneNumber: string, success?: () => void, fail?: (error: Error|string) => void): void;
95
90
  setApiToken(apiToken: string): void;
91
+ setVoipAppCode(appCode: string): void;
92
+ registerEvent(eventName: string, success: (...args: any[]) => void, fail?: (error?: Error | string) => void): void;
93
+ initializeVoIPParameters(supportsVideo?: boolean, ringtoneSound?: string, handleTypes?: number, success?: () => void, error?: (err: Error | string) => void): void;
94
+ speakerOn(success?: () => void, error?: (err: Error | string) => void): void;
95
+ speakerOff(success?: () => void, error?: (err: Error | string) => void): void;
96
+ mute(success?: () => void, error?: (err: Error | string) => void): void;
97
+ unmute(success?: () => void, error?: (err: Error | string) => void): void;
98
+ requestCallPermission(): void;
99
+ endCall(success?: () => void, error?: (err: Error | string) => void): void;
96
100
  }