I am using Twilio JavaScript client. I am able to make calls, capture callback events, connect, and disconnect. How do I implement a callback when a call is answered? I need to show a call timer after answering the call.
The Twilio js client has a Device property which has the following methods that you can use.
Twilio.Device.incoming(softPhoneIncoming);
Twilio.Device.connect(softPhoneConnect);
function softPhoneIncoming(conn) {
console.log(conn.parameters.From); // who is calling
conn.accept(); //This will accept the incoming phone call
}
function softPhoneConnect(conn)
{
// Called for all new connections, you could start the timer here
}
来源:https://stackoverflow.com/questions/26141528/twilio-javascript-client-callback-on-call-answer