Search code examples
javascriptruby-on-railstwiliophone-calltwilio-api

Phone hangups and client realises


I'm using Twilio API to make some calls from browser to phones and I have one question? Can the client realize when the user hangups his/her phone, raising an event and changing something in the view with js?

I'm trying to implement a single but user-friendly call/hangup modal to make the calls using twilio js library.


Solution

  • You can register an event listener on a Twilio Connection object to achieve that:

    var connection = Twilio.Device.connect();
    
    connection.disconnect(function(conn) {
      console.log("the call has ended");
    });