voice-react-native-sdk 2.0.0-preview.fork.3 → 2.0.0-preview.fork.5

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.
@@ -54,11 +54,14 @@ class CallListenerProxy implements Call.Listener {
54
54
 
55
55
  // stop sound and routing
56
56
  getMediaPlayerManager().stop();
57
- getAudioSwitchManager().getAudioSwitch().deactivate();
58
57
 
59
58
  // find call record & remove
60
59
  CallRecord callRecord = Objects.requireNonNull(getCallRecordDatabase().remove(new CallRecord(uuid)));
61
60
 
61
+ if (getCallRecordDatabase().getCollection().isEmpty()) {
62
+ getAudioSwitchManager().getAudioSwitch().deactivate();
63
+ }
64
+
62
65
  // take down notification
63
66
  getVoiceServiceApi().cancelActiveCallNotification(callRecord);
64
67
 
@@ -147,7 +150,9 @@ class CallListenerProxy implements Call.Listener {
147
150
  // stop audio & cancel notification
148
151
  getMediaPlayerManager().stop();
149
152
  getMediaPlayerManager().play(MediaPlayerManager.SoundTable.DISCONNECT);
150
- getAudioSwitchManager().getAudioSwitch().deactivate();
153
+ if (getCallRecordDatabase().getCollection().isEmpty()) {
154
+ getAudioSwitchManager().getAudioSwitch().deactivate();
155
+ }
151
156
  getVoiceServiceApi().cancelActiveCallNotification(callRecord);
152
157
 
153
158
  // notify JS layer
@@ -6,6 +6,7 @@
6
6
  //
7
7
 
8
8
  @import AVKit;
9
+ @import CallKit;
9
10
 
10
11
  #import "TwilioVoicePushRegistry.h"
11
12
  #import "TwilioVoiceReactNative.h"
@@ -780,9 +781,21 @@ RCT_EXPORT_METHOD(call_hold:(NSString *)uuid
780
781
  {
781
782
  TVOCall *call = [self getCallFromMap:uuid resolver:resolver];
782
783
  if (!call) return;
783
-
784
- [call setOnHold:onHold];
785
- [self resolvePromise:resolver value:@(call.isOnHold)];
784
+
785
+ // Persist the hold state to CallKit
786
+ // This is to fix a bug where when ending a call, if there was another call on hold, the call would not allow voice input/output.
787
+ CXSetHeldCallAction *holdAction = [[CXSetHeldCallAction alloc] initWithCallUUID:call.uuid onHold:onHold];
788
+ CXTransaction *transaction = [[CXTransaction alloc] initWithAction:holdAction];
789
+
790
+ [self.callKitCallController requestTransaction:transaction completion:^(NSError *error) {
791
+ if (error) {
792
+ [call setOnHold:onHold];
793
+ if (!onHold) {
794
+ [TwilioVoiceReactNative twilioAudioDevice].enabled = YES;
795
+ }
796
+ }
797
+ [self resolvePromise:resolver value:@(call.isOnHold)];
798
+ }];
786
799
  }
787
800
 
788
801
  RCT_EXPORT_METHOD(call_isOnHold:(NSString *)uuid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voice-react-native-sdk",
3
- "version": "2.0.0-preview.fork.3",
3
+ "version": "2.0.0-preview.fork.5",
4
4
  "description": "Twilio Voice React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",