prasannaboga
prasannaboga

Reputation: 1014

Twilio browser remember the microphone permissions for WebRTC

When we are loading pages with http every thing work as expected each call browser asks to grant media permission after allowing permission twilio is making the calls. I am updating twilio capability token before each call through ajax.

...
Twilio.Device.setup(twilio_token)
...

Problem is when the pages are loading with https because to remember media permission as given in twilio documentation

https://www.twilio.com/help/faq/twilio-client/can-the-browser-remember-the-microphone-permissions-for-webrtc

1st time when allow media permission we can make a call, after that to make next calls, device setup is not updated with new token to make calls getting following error

Cannot initiate call. Invalid token

How to make the device ready with new token for next calls, when browser remembers the media permission. I am thing after media allow only twilio device is setup ready.

Upvotes: 0

Views: 448

Answers (1)

Louis Lewis
Louis Lewis

Reputation: 1298

You could try handle the following event that the Twilio js client provides.

Twilio.Device.offline(softPhoneOffline);

function softPhoneOffline(device)
{
   console.log("softPhoneOffline");
   // Called on network connection lost.
   refreshtoken(); //Refresh Token 
}

function refreshtoken()
{
  Twilio.Device.setup(); // Just a sample, you would provide setup with a generated token
}

Regards

Louis

Upvotes: 1

Related Questions