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

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.
@@ -36,7 +36,12 @@
36
36
  break;
37
37
  }
38
38
  }
39
- NSAssert(uuid, @"No matching call invite");
39
+
40
+ if (!uuid) {
41
+ NSLog(@"No matching call invite for cancelled call SID %@. The invite may have already been accepted or removed.", cancelledCallInvite.callSid);
42
+ return;
43
+ }
44
+
40
45
  self.cancelledCallInviteMap[uuid] = cancelledCallInvite;
41
46
 
42
47
  [self sendEventWithName:kTwilioVoiceReactNativeScopeCallInvite
@@ -47,9 +52,9 @@
47
52
  kTwilioVoiceReactNativeVoiceErrorKeyError: @{
48
53
  kTwilioVoiceReactNativeVoiceErrorKeyCode: @(error.code),
49
54
  kTwilioVoiceReactNativeVoiceErrorKeyMessage: [error localizedDescription]}}];
50
-
55
+
51
56
  [self.callInviteMap removeObjectForKey:uuid];
52
-
57
+
53
58
  [self endCallWithUuid:[[NSUUID alloc] initWithUUIDString:uuid]];
54
59
  }
55
60
 
@@ -194,9 +194,14 @@ NSString * const kDefaultCallKitConfigurationName = @"Twilio Voice React Native"
194
194
 
195
195
  - (void)performAnswerVoiceCallWithUUID:(NSUUID *)uuid
196
196
  completion:(void(^)(BOOL success))completionHandler {
197
- NSAssert(self.callInviteMap[uuid.UUIDString], @"No call invite");
198
-
199
197
  TVOCallInvite *callInvite = self.callInviteMap[uuid.UUIDString];
198
+
199
+ if (!callInvite) {
200
+ NSLog(@"Call invite for UUID %@ not found. The invite was likely cancelled before the answer could be processed.", uuid.UUIDString);
201
+ completionHandler(NO);
202
+ return;
203
+ }
204
+
200
205
  TVOAcceptOptions *acceptOptions = [TVOAcceptOptions optionsWithCallInvite:callInvite block:^(TVOAcceptOptionsBuilder *builder) {
201
206
  builder.uuid = uuid;
202
207
  builder.callMessageDelegate = self;
@@ -292,7 +297,13 @@ NSString * const kDefaultCallKitConfigurationName = @"Twilio Voice React Native"
292
297
  - (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {
293
298
  [TwilioVoiceReactNative twilioAudioDevice].enabled = NO;
294
299
  [TwilioVoiceReactNative twilioAudioDevice].block();
295
-
300
+
301
+ if (!self.callInviteMap[action.callUUID.UUIDString]) {
302
+ NSLog(@"Cannot answer call: invite for UUID %@ no longer exists (likely cancelled).", action.callUUID.UUIDString);
303
+ [action fail];
304
+ return;
305
+ }
306
+
296
307
  [self performAnswerVoiceCallWithUUID:action.callUUID completion:^(BOOL success) {
297
308
  if (success) {
298
309
  NSLog(@"performAnswerVoiceCallWithUUID successful");
@@ -300,7 +311,7 @@ NSString * const kDefaultCallKitConfigurationName = @"Twilio Voice React Native"
300
311
  NSLog(@"performAnswerVoiceCallWithUUID failed");
301
312
  }
302
313
  }];
303
-
314
+
304
315
  [action fulfill];
305
316
  }
306
317
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voice-react-native-sdk",
3
- "version": "2.0.0-preview.fork.5",
3
+ "version": "2.0.0-preview.fork.6",
4
4
  "description": "Twilio Voice React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",