@vgroup/dialbox 0.0.47 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1318,26 +1318,54 @@ class TwilioService {
1318
1318
  this.initializeTwilioDevice();
1319
1319
  }
1320
1320
  initializeTwilioDevice() {
1321
- if (this.token) {
1322
- this.extensionService.getIncomingCallToken().subscribe((data) => {
1321
+ console.log('Initializing Twilio Device...');
1322
+ console.log('Token exists:', !!this.token);
1323
+ if (!this.token) {
1324
+ console.error('No token available for Twilio initialization');
1325
+ return;
1326
+ }
1327
+ this.extensionService.getIncomingCallToken().subscribe({
1328
+ next: (data) => {
1329
+ console.log('Received Twilio token');
1330
+ if (!data || !data.token) {
1331
+ console.error('Invalid token received from server');
1332
+ return;
1333
+ }
1323
1334
  this.incomingCallToken = data.token;
1324
1335
  localStorage.setItem('in-token', data.token);
1325
- this.device = new Device(this.incomingCallToken, {
1326
- allowIncomingWhileBusy: true,
1327
- // Add any other necessary options
1328
- });
1329
- this.device.register();
1330
- this.device.on('incoming', (call) => {
1331
- this.currentCall.next(call);
1332
- this.callType.next('INCOMING');
1333
- this.currentCallState.next('incoming');
1334
- });
1335
- this.device.on('error', (error) => {
1336
- console.error('Twilio Device Error:', error);
1337
- // Add error handling and reconnection logic
1338
- });
1339
- });
1340
- }
1336
+ try {
1337
+ console.log('Creating Twilio Device instance with token:', data.token.substring(0, 10) + '...');
1338
+ this.device = new Device(data.token, {
1339
+ allowIncomingWhileBusy: true,
1340
+ closeProtection: true
1341
+ });
1342
+ console.log('Registering device...');
1343
+ this.device.register();
1344
+ this.device.on('registered', () => {
1345
+ console.log('Twilio Device registered successfully');
1346
+ });
1347
+ this.device.on('incoming', (call) => {
1348
+ console.log('Incoming call received');
1349
+ this.currentCall.next(call);
1350
+ this.callType.next('INCOMING');
1351
+ this.currentCallState.next('incoming');
1352
+ });
1353
+ this.device.on('error', (error) => {
1354
+ console.error('Twilio Device Error:', error);
1355
+ // Attempt to reinitialize after delay
1356
+ setTimeout(() => this.initializeTwilioDevice(), 5000);
1357
+ });
1358
+ }
1359
+ catch (error) {
1360
+ console.error('Error initializing Twilio Device:', error);
1361
+ }
1362
+ },
1363
+ error: (error) => {
1364
+ console.error('Error getting Twilio token:', error);
1365
+ // Retry after delay
1366
+ setTimeout(() => this.initializeTwilioDevice(), 5000);
1367
+ }
1368
+ });
1341
1369
  }
1342
1370
  // onIncomingCall(){
1343
1371
  // this.device.on('incoming', (call:any) => {
@@ -2199,7 +2227,7 @@ class DialboxComponent {
2199
2227
  this.selectedCallerId = { number: contact.from };
2200
2228
  this.isSmartDialCall = true;
2201
2229
  setTimeout(() => {
2202
- this.isDialpadHidden = true;
2230
+ this.isDialpadHidden = false;
2203
2231
  }, 2000);
2204
2232
  this.callData.phone = contact.number;
2205
2233
  this.callData.name = contact.name;
@@ -2213,7 +2241,7 @@ class DialboxComponent {
2213
2241
  else {
2214
2242
  this.getUserCallSetting();
2215
2243
  setTimeout(() => {
2216
- this.isDialpadHidden = true;
2244
+ this.isDialpadHidden = false;
2217
2245
  }, 1000);
2218
2246
  this.getUserInformation(contact);
2219
2247
  // this.incomingCallsList.push(contact)