twiliotwilio-api

Twilio - can't detect that incoming call stopped calling


I use "@twilio/voice-sdk": "^2.0.1"

When incoming call is calling everything works fine - I can accept or reject this call and it works.

But when caller stops calling I can't detect that there is no more incoming call (so UI still shows accept/reject buttons).

device = new Device(token, {
  allowIncomingWhileBusy: true,
  appName: 'spotioWeb',
  closeProtection: true,
  logLevel: 'debug',
})

device.register()

device.on('incoming', (conn) => {
  onIncomingCall({ conn })

  conn.on('reject', () => { callEnded() })
  conn.on('disconnect', () => { callEnded() })
})

Solution

  • Twilio developer evangelist here.

    Can you try to listen for the cancel event as well. The docs say that it is fired when you call ignore on an incoming call or disconnect an outgoing call that hasn't been answered. But it would seem to me that an incoming call that ends before it has answered would also fulfill the idea of being cancelled.

    device.on('incoming', (conn) => {
      onIncomingCall({ conn })
    
      conn.on('reject', () => { callEnded() })
      conn.on('disconnect', () => { callEnded() })
      conn.on('cancel', () => { callEnded() })
    })
    

    Let me know if that helps at all.