Skip to content

Commit

Permalink
end CallKit call on call ending (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brazol authored Oct 19, 2023
1 parent f7f6e16 commit 6dea651
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/stream_video/lib/src/stream_video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const _tag = 'SV:Client';
const _idEvents = 1;
const _idAppState = 2;
const _idConnect = 3;
const _idActiveCall = 4;

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

if (pushNotificationManager != null) {
_subscriptions.add(
_idActiveCall,
_state.activeCall.listen(_onActiveCall),
);
}

return Result.success(tokenResult.data);
} catch (e, stk) {
_logger.e(() => '[connect] failed(${user.id}): $e');
Expand Down Expand Up @@ -421,6 +429,12 @@ class StreamVideo {
}
}

Future<void> _onActiveCall(Call? activeCall) async {
if (activeCall == null) {
await pushNotificationManager?.endAllCalls();
}
}

StreamSubscription<Call?> listenActiveCall(
void Function(Call? value)? onActiveCall,
) {
Expand Down

0 comments on commit 6dea651

Please sign in to comment.