Daniellesmith31
Daniellesmith31

Reputation: 49

Twilio - Recognising a user has ended a call

I am a junior developer currently working on creating our own phone system with Twilio. At the moment when I initiate a call from the client and the customer picks it up at their end its all working well until the user hangups. The call is still remaining connected until I end the call from the browser. How can I recognise that the user has ended the call from their end?

Upvotes: 3

Views: 1568

Answers (3)

Daniellesmith31
Daniellesmith31

Reputation: 49

For this I finally resolved it by setting the hub connection back to null on the disconnect.

this.connection.disconnect(() => {
                    this.connection = null;
                });

Upvotes: 0

Megan Speir
Megan Speir

Reputation: 3811

Danielle, hello! I'm Megan from Twilio.

It sounds like your scenario is related to making outgoing calls from the browser.

Have you followed the steps to hang up calls in the browser? Specifically:

Use .disconnect():

/* Log a message when a call disconnects. */
Twilio.Device.disconnect(function (conn) {
    $("#log").text("Call ended");
});

followed by a hangup() function using .disconnectAll():

/* A function to end a connection to Twilio. */
function hangup() {
    Twilio.Device.disconnectAll();
}

Consider tracking status from the client connection. When it is closed you can invoke the above functions.

Also, it might help if you turn on debugging in Client via:

Twilio.Device.setup(token, {debug: true});

The Javascript console will show all the low level events received.

Please let me know if this helps.

Upvotes: 1

ddavison
ddavison

Reputation: 29032

Looks like there is a callback in the Twilio API called "completed"

The call was answered and has ended normally.

Source

Upvotes: 1

Related Questions