Jacob Oscarson
Jacob Oscarson

Reputation: 6403

Twilio, detect if other side picks up?

I'm writing a Twilio iOS app and have a question about the lifecycle of calls: If i start a call (using TCDevice connect:delegate:) I'd like to know if the call have been picked up by the other side. I've found TCConnectionDelegate connectionDidDisconnect: to track that a call hasn't been picked up, but is there anything similar to detect if a call has been picked up?

Upvotes: 0

Views: 845

Answers (1)

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

So, lets start by clarifying what your set up is and make sure I understand the specific question you are asking.

It sounds like you are using the <Dial> verb to connect an instance of Twilio Client to another endpoint (PSTN, SIP, Client?). If that is the case then whats really under the covers is you have a phone call with two legs. The first leg connects your app to Twilio via Twilio Client. The second leg connects Twilio with an endpoint (PSTN, SIP, Client) via the <Dial> verb.

It sounds like you are asking how to know if the second leg is answered or not.

If I have the question correct, unfortunately there isn't really a way to find this out directly from the Twilio Client SDK, but you can do it from a server-side app, then relay the result to your iOS app.

The <Dial> verb includes an attribute named action which lets you specify a web application URL for Twilio to request when the the second leg call ends. That request includes a parameter named DialCallStatus which will tell you why the called ended, including if there was no answer.

<Dial action="http://www.example.com/callstatus">
    <Number>+15555555555</Number>
</Dial>

Once your web application knows the DialCallStatus, if you want to relay it back to your iOS app you can use iOS's push notifications, or you can look at using something like Pusher, which may be a more light-weight way to send the notification.

Upvotes: 2

Related Questions