@vgroup/dialbox 0.0.60 → 0.0.62
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.
- package/esm2020/lib/dialbox.component.mjs +1 -9
- package/esm2020/lib/service/twilio.service.mjs +7 -4
- package/fesm2015/vgroup-dialbox.mjs +76 -82
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +76 -82
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/service/twilio.service.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1294,10 +1294,82 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1294
1294
|
}]
|
|
1295
1295
|
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: IpAddressService }]; } });
|
|
1296
1296
|
|
|
1297
|
+
class NotificationService {
|
|
1298
|
+
constructor(twilioService) {
|
|
1299
|
+
this.twilioService = twilioService;
|
|
1300
|
+
this.redirectUrl = window.location.href;
|
|
1301
|
+
if ('serviceWorker' in navigator) {
|
|
1302
|
+
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerMessage.bind(this));
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
showNotification(callData) {
|
|
1306
|
+
this.twilioAuthId = callData.customParameters.get('twilioAuthId');
|
|
1307
|
+
this.twilioCallData = callData;
|
|
1308
|
+
const incomingNumber = callData.parameters.From;
|
|
1309
|
+
const callerName = callData.customParameters.get('name');
|
|
1310
|
+
const callerImage = callData.customParameters.get('image');
|
|
1311
|
+
if (('serviceWorker' in navigator)) {
|
|
1312
|
+
navigator.serviceWorker.ready.then((registration) => {
|
|
1313
|
+
const options = {
|
|
1314
|
+
body: `Incoming call from ${callerName || incomingNumber}`,
|
|
1315
|
+
icon: callerImage,
|
|
1316
|
+
actions: [
|
|
1317
|
+
{
|
|
1318
|
+
action: 'accept',
|
|
1319
|
+
title: 'Accept',
|
|
1320
|
+
icon: '../../../assets/images/notification-icons/call-accept-icon.png'
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
action: 'reject',
|
|
1324
|
+
title: 'Reject',
|
|
1325
|
+
icon: '../../../assets/images/notification-icons/call-reject-icon.jpg'
|
|
1326
|
+
}
|
|
1327
|
+
],
|
|
1328
|
+
data: {
|
|
1329
|
+
url: this.redirectUrl,
|
|
1330
|
+
},
|
|
1331
|
+
requireInteraction: true,
|
|
1332
|
+
};
|
|
1333
|
+
registration.showNotification('Icoming Call', options);
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
handleServiceWorkerMessage(event) {
|
|
1338
|
+
if (!event.data)
|
|
1339
|
+
return;
|
|
1340
|
+
switch (event.data.action) {
|
|
1341
|
+
case 'accept':
|
|
1342
|
+
this.onNotificationAccept();
|
|
1343
|
+
break;
|
|
1344
|
+
case 'reject':
|
|
1345
|
+
this.onNotificationReject();
|
|
1346
|
+
break;
|
|
1347
|
+
default:
|
|
1348
|
+
console.log('default action:');
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
onNotificationAccept() {
|
|
1353
|
+
this.twilioService.callhandleFromNotification.next({ callStatus: 'accept' });
|
|
1354
|
+
}
|
|
1355
|
+
onNotificationReject() {
|
|
1356
|
+
this.twilioService.callhandleFromNotification.next({ callStatus: 'reject' });
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
NotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NotificationService, deps: [{ token: TwilioService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1360
|
+
NotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NotificationService, providedIn: 'root' });
|
|
1361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NotificationService, decorators: [{
|
|
1362
|
+
type: Injectable,
|
|
1363
|
+
args: [{
|
|
1364
|
+
providedIn: 'root'
|
|
1365
|
+
}]
|
|
1366
|
+
}], ctorParameters: function () { return [{ type: TwilioService }]; } });
|
|
1367
|
+
|
|
1297
1368
|
class TwilioService {
|
|
1298
|
-
constructor(http, extensionService) {
|
|
1369
|
+
constructor(http, extensionService, notificationSerivce) {
|
|
1299
1370
|
this.http = http;
|
|
1300
1371
|
this.extensionService = extensionService;
|
|
1372
|
+
this.notificationSerivce = notificationSerivce;
|
|
1301
1373
|
this.openInProgressDialpad = new BehaviorSubject(false);
|
|
1302
1374
|
this.currentCall = new BehaviorSubject(null);
|
|
1303
1375
|
this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
|
|
@@ -1331,6 +1403,7 @@ class TwilioService {
|
|
|
1331
1403
|
this.currentCall.next(call);
|
|
1332
1404
|
this.callType.next('INCOMING');
|
|
1333
1405
|
this.currentCallState.next('incoming');
|
|
1406
|
+
this.notificationSerivce.showNotification(call);
|
|
1334
1407
|
});
|
|
1335
1408
|
this.device.on('error', (error) => {
|
|
1336
1409
|
console.error('Twilio Device Error:', error);
|
|
@@ -1431,14 +1504,14 @@ class TwilioService {
|
|
|
1431
1504
|
return this.http.get(environment.apiUrl + '/utilities/softphone/check/countryCode/' + dialledNo, httpOptions);
|
|
1432
1505
|
}
|
|
1433
1506
|
}
|
|
1434
|
-
TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }, { token: ExtensionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1507
|
+
TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }, { token: ExtensionService }, { token: NotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1435
1508
|
TwilioService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, providedIn: 'root' });
|
|
1436
1509
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, decorators: [{
|
|
1437
1510
|
type: Injectable,
|
|
1438
1511
|
args: [{
|
|
1439
1512
|
providedIn: 'root'
|
|
1440
1513
|
}]
|
|
1441
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ExtensionService }]; } });
|
|
1514
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ExtensionService }, { type: NotificationService }]; } });
|
|
1442
1515
|
|
|
1443
1516
|
const GlobalConstant = {
|
|
1444
1517
|
ErrorMsg500: "Unable to process request. Please try again later.",
|
|
@@ -1446,77 +1519,6 @@ const GlobalConstant = {
|
|
|
1446
1519
|
dedicatedNumText: 'C2C Number'
|
|
1447
1520
|
};
|
|
1448
1521
|
|
|
1449
|
-
class NotificationService {
|
|
1450
|
-
constructor(twilioService) {
|
|
1451
|
-
this.twilioService = twilioService;
|
|
1452
|
-
this.redirectUrl = window.location.href;
|
|
1453
|
-
if ('serviceWorker' in navigator) {
|
|
1454
|
-
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerMessage.bind(this));
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
showNotification(callData) {
|
|
1458
|
-
this.twilioAuthId = callData.customParameters.get('twilioAuthId');
|
|
1459
|
-
this.twilioCallData = callData;
|
|
1460
|
-
const incomingNumber = callData.parameters.From;
|
|
1461
|
-
const callerName = callData.customParameters.get('name');
|
|
1462
|
-
const callerImage = callData.customParameters.get('image');
|
|
1463
|
-
if (('serviceWorker' in navigator)) {
|
|
1464
|
-
navigator.serviceWorker.ready.then((registration) => {
|
|
1465
|
-
const options = {
|
|
1466
|
-
body: `Incoming call from ${callerName || incomingNumber}`,
|
|
1467
|
-
icon: callerImage,
|
|
1468
|
-
actions: [
|
|
1469
|
-
{
|
|
1470
|
-
action: 'accept',
|
|
1471
|
-
title: 'Accept',
|
|
1472
|
-
icon: '../../../assets/images/notification-icons/call-accept-icon.png'
|
|
1473
|
-
},
|
|
1474
|
-
{
|
|
1475
|
-
action: 'reject',
|
|
1476
|
-
title: 'Reject',
|
|
1477
|
-
icon: '../../../assets/images/notification-icons/call-reject-icon.jpg'
|
|
1478
|
-
}
|
|
1479
|
-
],
|
|
1480
|
-
data: {
|
|
1481
|
-
url: this.redirectUrl,
|
|
1482
|
-
},
|
|
1483
|
-
requireInteraction: true,
|
|
1484
|
-
};
|
|
1485
|
-
registration.showNotification('Icoming Call', options);
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
handleServiceWorkerMessage(event) {
|
|
1490
|
-
if (!event.data)
|
|
1491
|
-
return;
|
|
1492
|
-
switch (event.data.action) {
|
|
1493
|
-
case 'accept':
|
|
1494
|
-
this.onNotificationAccept();
|
|
1495
|
-
break;
|
|
1496
|
-
case 'reject':
|
|
1497
|
-
this.onNotificationReject();
|
|
1498
|
-
break;
|
|
1499
|
-
default:
|
|
1500
|
-
console.log('default action:');
|
|
1501
|
-
break;
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
onNotificationAccept() {
|
|
1505
|
-
this.twilioService.callhandleFromNotification.next({ callStatus: 'accept' });
|
|
1506
|
-
}
|
|
1507
|
-
onNotificationReject() {
|
|
1508
|
-
this.twilioService.callhandleFromNotification.next({ callStatus: 'reject' });
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
NotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NotificationService, deps: [{ token: TwilioService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1512
|
-
NotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NotificationService, providedIn: 'root' });
|
|
1513
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: NotificationService, decorators: [{
|
|
1514
|
-
type: Injectable,
|
|
1515
|
-
args: [{
|
|
1516
|
-
providedIn: 'root'
|
|
1517
|
-
}]
|
|
1518
|
-
}], ctorParameters: function () { return [{ type: TwilioService }]; } });
|
|
1519
|
-
|
|
1520
1522
|
class IncomingCallComponent {
|
|
1521
1523
|
constructor(extensionService, twilioService, notificationSerivce) {
|
|
1522
1524
|
this.extensionService = extensionService;
|
|
@@ -2223,14 +2225,6 @@ class DialboxComponent {
|
|
|
2223
2225
|
try {
|
|
2224
2226
|
this.getContactList();
|
|
2225
2227
|
this.getUserCallSetting();
|
|
2226
|
-
// Subscribe to incoming calls and show dialpad when a call comes in
|
|
2227
|
-
this.subscriptions.add(this.twilioService.currentCall.subscribe((call) => {
|
|
2228
|
-
if (call && call.parameters && call.parameters.Direction === 'incoming') {
|
|
2229
|
-
// Show the dialpad when an incoming call is received
|
|
2230
|
-
this._isDialpadHidden = false;
|
|
2231
|
-
this.incomingCallInitiated.emit();
|
|
2232
|
-
}
|
|
2233
|
-
}));
|
|
2234
2228
|
// Subscribe to dial number events
|
|
2235
2229
|
const sub1 = this.twilioService.dialNumberFromOtherModule.subscribe((contact) => {
|
|
2236
2230
|
if (contact.number) {
|