I'm using Twilio.Device in an Angular app and I need to display a message if the call failed due to an invalid number. I know that you can call Twilio's REST API to get the call status, but is there a way to get the status without making that extra call?
For example, I was hoping that the connection
object that you get back in the disconnect
handler would give you the status, like this:
Twilio.Device.disconnect(function(connection) {
if (connection.status === 'failed') {
// display error message
}
});
However, that's either not possible or I'm not looking in the right place.
Another idea I had is when I set debug
to true
, I can see this helpful log when making a call with an invalid number:
[Connection] Received HANGUP from gateway
[Connection] Disconnecting...
But is there any way to access that HANGUP
event?
Thanks in advance!