Skip to content

Commit cbb1cc8

Browse files
committed
feat: show call end & missed call notifcations
1 parent a971ad1 commit cbb1cc8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/web_callkit_web.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,17 @@ class WebCallkitWeb extends WebCallkitPlatform {
606606
if (event is DisconnectCallEvent) {
607607
_onDisconnectListener?.call(event.uuid, event.response, CKActionSource.api);
608608
}
609+
bool isMissedCall = event is DisconnectCallEvent ? event.response == CKDisconnectResponse.missed : false;
610+
if(_configuration.notifyOnCallEnd && !isMissedCall) {
611+
final notification = _notificationManager.getNotification(event.uuid);
612+
final n = _generateNotification(call: call, capabilities: call.capabilities, metadata: notification?.metadata, requireInteraction: false);
613+
await _notificationManager.add(n, flags: {});
614+
}
615+
if(_configuration.notifyOnMissedCall && isMissedCall) {
616+
final notification = _notificationManager.getNotification(event.uuid);
617+
final n = _generateNotification(call: call, capabilities: call.capabilities, metadata: notification?.metadata, description: "Missed Call", requireInteraction: false);
618+
await _notificationManager.add(n, flags: {});
619+
}
609620
_stopCallTimer(id);
610621
break;
611622
}
@@ -712,9 +723,11 @@ class WebCallkitWeb extends WebCallkitPlatform {
712723
//ignore: unused_element
713724
Duration? offset,
714725
bool? silent,
726+
String? description,
727+
bool? requireInteraction,
715728
}) {
716729
final title = _getTitle(call);
717-
final body = _getDescription(call);
730+
final body = description ?? _getDescription(call);
718731
final actions = _getActions(call);
719732
final icon = _getIcon(call);
720733

@@ -726,7 +739,7 @@ class WebCallkitWeb extends WebCallkitPlatform {
726739
actions: actions,
727740
icon: icon,
728741
silent: silent,
729-
requireInteraction: true,
742+
requireInteraction: requireInteraction ?? true,
730743
renotify: true,
731744
data: call.data,
732745
timestamp: currentTime.millisecondsSinceEpoch,

0 commit comments

Comments
 (0)