0
votes

I am using the the iOS client quick start project hosted on https://github.com/twilio/voice-callkit-quickstart-objc

on server I am using python (as recommended on github project)

When I clicked on "Place outgoing call" it worked fine and I got "Welcome to Twilio" voice. Great!

Then I changed the code a bit and tried to make an outgoing call to specific number. Here's the modified code

Button click event

- (IBAction)placeCall:(id)sender {
    NSUUID *uuid = [NSUUID UUID];
    NSString *handle = @"Real Number";

    [self performStartCallActionWithUUID:uuid handle:handle];
}

Here's the CallKit handle

- (void)performStartCallActionWithUUID:(NSUUID *)uuid handle:(NSString *)handle {
    if (uuid == nil || handle == nil) {
        return;
    }

    CXHandle *callHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
    CXStartCallAction *startCallAction = [[CXStartCallAction alloc] initWithCallUUID:uuid handle:callHandle];
    CXTransaction *transaction = [[CXTransaction alloc] initWithAction:startCallAction];

    [self.callKitCallController requestTransaction:transaction completion:^(NSError *error) {
        if (error) {
            NSLog(@"StartCallAction transaction request failed: %@", [error localizedDescription]);
        } else {
            NSLog(@"StartCallAction transaction request successful");

            CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
            callUpdate.remoteHandle = callHandle;
            callUpdate.supportsDTMF = YES;
            callUpdate.supportsHolding = NO;
            callUpdate.supportsGrouping = NO;
            callUpdate.supportsUngrouping = NO;
            callUpdate.hasVideo = NO;

            [self.callKitProvider reportCallWithUUID:uuid updated:callUpdate];
        }
    }];
}

And the number to call

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

    [[VoiceClient sharedInstance] configureAudioSession];

    NSDictionary *toParam = @{@"To": @"+14805058877"};
    //THIS IS WHERE WE NEED TO INSERT CALLING NUMBER
    self.outgoingCall = [[VoiceClient sharedInstance] call:[self fetchAccessToken]
                                                    params:toParam
                                                  delegate:self];

    if (!self.outgoingCall) {
        [action fail];
    } else {
        self.outgoingCall.uuid = action.callUUID;
        [self toggleUIState:NO];
        [self startSpin];

        [action fulfillWithDateStarted:[NSDate date]];
    }
}

No matter what I enter in the parameter value I always get "Welcome to Twilio" msg. I need to know if I need change anything on the Python server or in the iOS client code. Please help!

1

1 Answers

0
votes

Twilio developer evangelist here.

Have you set your TwiML application up correctly? The Voice Request URL should be pointing to your python server. I only ask as the message from the Python server, which comes from this line in the code, should be "Congratulations! You have made your first oubound call! Good bye." and you said it was "Welcome to Twilio"

Once you are definitely set up pointing at your Python app, once you have made your first outbound call you will get that message. Now you need to update your Python app as well as the iOS app.

You're sending a parameter To with the number you're trying to call. You need to change the Python so that it reads that number and outputs the TwiML that will dial that number.

That should look a bit like this:

@app.route('/outgoing', methods=['GET', 'POST'])
def outgoing():
  resp = twilio.twiml.Response()
  resp.dial(request.form['To'])
  return str(resp)

Let me know if that helps at all.