Compare commits
3 Commits
2026.01.24
...
2026.01.24
| Author | SHA1 | Date | |
|---|---|---|---|
| b95d1dc461 | |||
| 59df695530 | |||
| 03b6e5d70f |
@@ -7016,7 +7016,7 @@ class TWP_Admin {
|
|||||||
<div class="phone-interface">
|
<div class="phone-interface">
|
||||||
<div class="phone-display">
|
<div class="phone-display">
|
||||||
<div id="phone-status">Ready</div>
|
<div id="phone-status">Ready</div>
|
||||||
<div id="device-connection-status" style="font-size: 12px; color: #999; margin-top: 5px;">Connecting...</div>
|
<div id="device-connection-status" style="font-size: 12px; color: #999; margin-top: 5px;">Loading...</div>
|
||||||
<div id="phone-number-display"></div>
|
<div id="phone-number-display"></div>
|
||||||
<div id="call-timer" style="display: none;">00:00</div>
|
<div id="call-timer" style="display: none;">00:00</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -7807,7 +7807,7 @@ class TWP_Admin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
console.log('Twilio Device created with audio constraints:', audioConstraints);
|
console.log('Twilio Device created with audio constraints:', audioConstraints);
|
||||||
|
|
||||||
// Set up event handlers BEFORE registering
|
// Set up event handlers BEFORE registering
|
||||||
// Device registered and ready
|
// Device registered and ready
|
||||||
device.on('registered', function() {
|
device.on('registered', function() {
|
||||||
@@ -7894,7 +7894,7 @@ class TWP_Admin {
|
|||||||
|
|
||||||
// Register device AFTER setting up event handlers
|
// Register device AFTER setting up event handlers
|
||||||
await device.register();
|
await device.register();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error setting up Twilio Device:', error);
|
console.error('Error setting up Twilio Device:', error);
|
||||||
showError('Failed to setup device: ' + error.message);
|
showError('Failed to setup device: ' + error.message);
|
||||||
@@ -8233,16 +8233,33 @@ class TWP_Admin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if SDK loaded and initialize
|
// Check if SDK loaded and initialize
|
||||||
|
// Poll for Twilio SDK availability (window.load may not fire on mobile)
|
||||||
|
var sdkCheckAttempts = 0;
|
||||||
|
var maxSdkCheckAttempts = 50; // 5 seconds max
|
||||||
|
|
||||||
|
function checkAndInitialize() {
|
||||||
|
sdkCheckAttempts++;
|
||||||
|
|
||||||
|
if (typeof Twilio !== 'undefined' && Twilio.Device) {
|
||||||
|
console.log('Twilio SDK loaded successfully');
|
||||||
|
initializeBrowserPhone();
|
||||||
|
} else if (sdkCheckAttempts < maxSdkCheckAttempts) {
|
||||||
|
// Keep checking every 100ms
|
||||||
|
setTimeout(checkAndInitialize, 100);
|
||||||
|
} else {
|
||||||
|
showError('Twilio Voice SDK failed to load. Please check your internet connection and try refreshing the page.');
|
||||||
|
console.error('Twilio SDK not found after ' + sdkCheckAttempts + ' attempts.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start checking after a brief delay
|
||||||
|
setTimeout(checkAndInitialize, 500);
|
||||||
|
|
||||||
|
// Also keep the window.load as backup for desktop
|
||||||
$(window).on('load', function() {
|
$(window).on('load', function() {
|
||||||
setTimeout(function() {
|
if (typeof Twilio !== 'undefined' && !device) {
|
||||||
if (typeof Twilio === 'undefined') {
|
initializeBrowserPhone();
|
||||||
showError('Twilio Voice SDK failed to load. Please check your internet connection and try refreshing the page.');
|
}
|
||||||
console.error('Twilio SDK not found. Script may be blocked or failed to load.');
|
|
||||||
} else {
|
|
||||||
console.log('Twilio SDK loaded successfully');
|
|
||||||
initializeBrowserPhone();
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clean up on page unload
|
// Clean up on page unload
|
||||||
|
|||||||
Reference in New Issue
Block a user