twilio / voice-quickstart-ios

Twilio Voice Quickstart for iOS with Swift
MIT License
183 stars 97 forks source link

Call Extension for contact #475

Closed milo-sedarat closed 3 years ago

milo-sedarat commented 3 years ago

Description

I am using React-Native to handle the call via Twilio. All works as expected. However, if we click the call from the contact on iPhone, then it doesn't do anything. I tested a similar app called "TextNow", and it can make the call directly from the contact list of iPhone. Do you have any suggestions on how we can resolve it?

Steps to Reproduce

  1. Receive the call
  2. The call logs show on the contact
  3. Click the contact

Code

React Native. I've used React Native twilio programmable voice.

Expected Behavior

It should open the app and make the call

Actual Behavior

It doesn't open anything.

Reproduces How Often

100%

Versions

All relevant version information for the issue.

Voice iOS SDK

React Native.

Xcode

8.3.3

iOS Version

Ios 10

iOS Device

Iphone 6, iPhone 8 plus, iphone X

bobiechen-twilio commented 3 years ago

Hi @v-grant

Thanks for reaching out. Although the quickstart does not demonstrate this function, but I believe if the contact is configured and linked with your iOS app that uses the Voice SDK, you should receive a [CXProviderDelegate provider:performStartCallAction:] callback and you should be able to continue from there and eventually make outbound calls via the SDK API.

milo-sedarat commented 3 years ago

Hi, @bobiechen-twilio Thanks for your reply. I can see the call logs on my iPhone once I received the incoming call. However, if I am going to make the outbound call from the call logs, I can't see my App on the caller's list. How can I register this Twilio-based app on the caller list on iPhone?

milo-sedarat commented 3 years ago

`- (void)provider:(CXProvider )provider performStartCallAction:(CXStartCallAction )action { NSLog(@"provider:performStartCallAction");

self.audioDevice.enabled = NO;
self.audioDevice.block();

[self.callKitProvider reportOutgoingCallWithUUID:action.callUUID startedConnectingAtDate:[NSDate date]];

weak typeof(self) weakSelf = self; [self performVoiceCallWithUUID:action.callUUID client:nil completion:^(BOOL success) { strong typeof(self) strongSelf = weakSelf; if (success) { [strongSelf.callKitProvider reportOutgoingCallWithUUID:action.callUUID connectedAtDate:[NSDate date]]; [action fulfill]; } else { [action fail]; } }]; }`

This is the performStartCallAction handler from 'react-native-twilio-programmable-voice'

bobiechen-twilio commented 3 years ago

Hi @v-grant

While I am still trying adding an IntentExtension to the quickstart, perhaps this tutorial could give you the similar idea how to initiate a call from system contacts or call history: https://medium.com/textnowengineering/ios-hands-free-calling-with-siri-and-intents-e05879c47e71.

bobiechen-twilio commented 3 years ago

Okay I think I got this figured out a bit further and am able to initiate a call from the recents (call history):

  1. You need to specify the supported handle types (this step is important)
  CXProviderConfiguration *configuration = ...
  configuration.supportedHandleTypes = [NSSet setWithArray:@[@(CXHandleTypeGeneric), @(CXHandleTypePhoneNumber)]];
  1. Import the Intents framework and implement the delegate method
// AppDelegate.m

@import Intents;

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler {
    INStartAudioCallIntent *callIntent = (INStartAudioCallIntent *)userActivity.interaction.intent;
    NSString *handle = callIntent.contacts[0].personHandle.value;

    // Use the handle to start a call

    return YES;
}

Check out the docs of INStartAudioCallIntent for more information about the contacts object.

milo-sedarat commented 3 years ago

Hi @bobiechen-twilio , Thank you very much for your help. Let me try it on today.