Compare commits
1 Commits
2026.01.24
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 03692608cc |
@@ -7445,6 +7445,11 @@ class TWP_Admin {
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Preload and preconnect for faster loading -->
|
||||
<link rel="preload" href="https://unpkg.com/@twilio/voice-sdk@2.11.0/dist/twilio.min.js" as="script">
|
||||
<link rel="dns-prefetch" href="//unpkg.com">
|
||||
<link rel="dns-prefetch" href="//chunderw-vpc-gll.twilio.com">
|
||||
<link rel="preconnect" href="https://chunderw-vpc-gll.twilio.com" crossorigin>
|
||||
<!-- Twilio Voice SDK v2 from unpkg CDN -->
|
||||
<script src="https://unpkg.com/@twilio/voice-sdk@2.11.0/dist/twilio.min.js"></script>
|
||||
<script>
|
||||
@@ -8235,7 +8240,7 @@ class TWP_Admin {
|
||||
// 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
|
||||
var maxSdkCheckAttempts = 100; // 5 seconds max (100 * 50ms)
|
||||
|
||||
function checkAndInitialize() {
|
||||
sdkCheckAttempts++;
|
||||
@@ -8244,16 +8249,23 @@ class TWP_Admin {
|
||||
console.log('Twilio SDK loaded successfully');
|
||||
initializeBrowserPhone();
|
||||
} else if (sdkCheckAttempts < maxSdkCheckAttempts) {
|
||||
// Keep checking every 100ms
|
||||
setTimeout(checkAndInitialize, 100);
|
||||
// Keep checking every 50ms for faster response
|
||||
setTimeout(checkAndInitialize, 50);
|
||||
} 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);
|
||||
// Check immediately - SDK script is synchronous so should be loaded
|
||||
// If not ready yet (mobile), polling will catch it
|
||||
if (typeof Twilio !== 'undefined' && Twilio.Device) {
|
||||
console.log('Twilio SDK already loaded');
|
||||
initializeBrowserPhone();
|
||||
} else {
|
||||
// Start polling immediately
|
||||
checkAndInitialize();
|
||||
}
|
||||
|
||||
// Also keep the window.load as backup for desktop
|
||||
$(window).on('load', function() {
|
||||
|
||||
Reference in New Issue
Block a user