Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: end CallKit call on call ending #504

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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