From 95b54ce2df7bf7d6cc5d38191429157c321d61f0 Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 13 Aug 2025 15:20:14 -0700 Subject: [PATCH] Fix browser phone Twilio SDK v2 API compatibility issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update makeCall function to use async/await with new SDK - Wrap connect params in {params: params} object as required by SDK v2 - Make setupTwilioDevice async and await device.register() - Add proper error handling for Promise-based API calls 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- assets/js/browser-phone-frontend.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/js/browser-phone-frontend.js b/assets/js/browser-phone-frontend.js index 5b7737e..59d22d7 100644 --- a/assets/js/browser-phone-frontend.js +++ b/assets/js/browser-phone-frontend.js @@ -102,7 +102,7 @@ /** * Setup Twilio Device */ - function setupTwilioDevice(token) { + async function setupTwilioDevice(token) { // Check if Twilio SDK is loaded if (typeof Twilio === 'undefined' || !Twilio.Device) { updateStatus('offline', 'Twilio SDK not loaded'); @@ -138,7 +138,8 @@ isConnected = false; }); - twilioDevice.register(); + // Register device asynchronously + await twilioDevice.register(); } catch (error) { console.error('Failed to setup Twilio Device:', error); @@ -287,7 +288,7 @@ /** * Make outbound call */ - function makeCall(number, callerId) { + async function makeCall(number, callerId) { if (currentCall) { showMessage('Already in a call', 'error'); return; @@ -302,8 +303,10 @@ }; try { - currentCall = twilioDevice.connect(params); + console.log('Making call with params:', params); + currentCall = await twilioDevice.connect({params: params}); + // Setup call event handlers currentCall.on('accept', function() { updateCallState('connected'); showCallInfo('Connected');