Search code examples
iosswifttwiliovoip

Making a call from a Twilio client to another Twilio client directly


what I am trying to achieve is to make a VoIP call from an iPhone to an iPhone using Twilio.

To do that I'm using the iOS SDK, the Twilio Voice to be more specific as the iOS SDK is superseded.

I have a server that generates an access token and when I create a call the Twilio API would make a request to my server and I would return a <Dial /> keyword with the client name and the connection would be established.

The problem is, this counts as two calls(iOS app to Twilio is the first one and when I return a TwML <Dial /> response is the second one) so the price is practically doubled.

Is there a way to make it as a single iOS app to an iOS app call? All my server does is to generate the TWiML using the parameters that are sent from the client anyway.

Oh and also in the documentation there are some talks about capability tokens but all the current documentation is using Access Tokens.

Are capability tokens relics of the past for the older API?

Thanks


Solution

  • Twilio developer evangelist here.

    Twilio calls are always priced per leg, so in a call between two people you do always pay for the outgoing leg and the incoming leg. They may also have different lengths, if the outgoing call goes through some other TwiML before making the <Dial> for example.

    However, if all you want to do is make calls between applications and you don't need to be able to make calls to the phone network then can I recommend you take a look at the Twilio Video project. While it is called "Video" you can use the SDK to make audio calls between apps too. And if you choose to create peer-to-peer rooms, then the audio stream is sent directly between the two devices and not charged as a call leg at all. The only extra thing you need to do is to generate the call notifications yourself.

    As for capability tokens, they are indeed a left over bit of documentation. Capability tokens have mostly been renamed as access tokens so you can use them interchangeably. If you investigate the Video SDK, then everything will be Access Tokens too.