Reputation: 1014
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
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
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