Skip to content

Commit 6dea651

Browse files
authored
end CallKit call on call ending (#504)
1 parent f7f6e16 commit 6dea651

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/stream_video/lib/src/stream_video.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const _tag = 'SV:Client';
5151
const _idEvents = 1;
5252
const _idAppState = 2;
5353
const _idConnect = 3;
54+
const _idActiveCall = 4;
5455

5556
const _defaultCoordinatorRpcUrl = 'https://video.stream-io-api.com/video';
5657
const _defaultCoordinatorWsUrl = 'wss://video.stream-io-api.com/video/connect';
@@ -322,6 +323,13 @@ class StreamVideo {
322323
// Register device with push notification manager.
323324
pushNotificationManager?.registerDevice();
324325

326+
if (pushNotificationManager != null) {
327+
_subscriptions.add(
328+
_idActiveCall,
329+
_state.activeCall.listen(_onActiveCall),
330+
);
331+
}
332+
325333
return Result.success(tokenResult.data);
326334
} catch (e, stk) {
327335
_logger.e(() => '[connect] failed(${user.id}): $e');
@@ -421,6 +429,12 @@ class StreamVideo {
421429
}
422430
}
423431

432+
Future<void> _onActiveCall(Call? activeCall) async {
433+
if (activeCall == null) {
434+
await pushNotificationManager?.endAllCalls();
435+
}
436+
}
437+
424438
StreamSubscription<Call?> listenActiveCall(
425439
void Function(Call? value)? onActiveCall,
426440
) {

0 commit comments

Comments
 (0)