forked from eatvio/eatvio_app
Revert "feat(video_calls): added system ui for call and navigation to the app"
This reverts commit ea5fced456.
This commit is contained in:
@@ -30,7 +30,6 @@ class VideoCallCallKitCoordinator {
|
||||
final VideoCallSessionCubit? _videoCallSessionCubit;
|
||||
|
||||
StreamSubscription<CallEvent?>? _eventSubscription;
|
||||
AppLifecycleListener? _lifecycleListener;
|
||||
final Map<String, CallKitParams> _callKitParamsById = {};
|
||||
final Set<String> _acceptHandledCallKitIds = {};
|
||||
final Set<String> _suppressedEndCallKitIds = {};
|
||||
@@ -50,17 +49,16 @@ class VideoCallCallKitCoordinator {
|
||||
|
||||
if (Platform.isIOS) {
|
||||
_voipDiagnosticsChannel.setMethodCallHandler((call) async {
|
||||
if (call.method == 'voipDiagnosticsUpdated') {
|
||||
_scheduleNativeVoipDiagnosticsDrain();
|
||||
switch (call.method) {
|
||||
case 'voipDiagnosticsUpdated':
|
||||
_scheduleNativeVoipDiagnosticsDrain();
|
||||
case 'acceptedVoipCall':
|
||||
await _handleNativeAcceptedVoipCall(call.arguments);
|
||||
}
|
||||
});
|
||||
await _firebaseApi.registerPushToken();
|
||||
_lifecycleListener = AppLifecycleListener(
|
||||
onResume: () => unawaited(_openActiveCallKitCallIfNeeded()),
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scheduleNativeVoipDiagnosticsDrain();
|
||||
unawaited(_openActiveCallKitCallIfNeeded());
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -83,9 +81,7 @@ class VideoCallCallKitCoordinator {
|
||||
|
||||
void dispose() {
|
||||
unawaited(_eventSubscription?.cancel());
|
||||
_lifecycleListener?.dispose();
|
||||
_eventSubscription = null;
|
||||
_lifecycleListener = null;
|
||||
_callKitParamsById.clear();
|
||||
_initialized = false;
|
||||
}
|
||||
@@ -289,53 +285,6 @@ class VideoCallCallKitCoordinator {
|
||||
return _paramsForCallId(id);
|
||||
}
|
||||
|
||||
/// When the user opens the app from the system CallKit UI (e.g. taps "Итвио"),
|
||||
/// navigate to the in-app call screen for an already-accepted active call.
|
||||
Future<void> _openActiveCallKitCallIfNeeded() async {
|
||||
if (!Platform.isIOS) return;
|
||||
if (_cubit.state.connectPhase != VideoCallConnectPhase.idle) return;
|
||||
|
||||
final activeCalls = await FlutterCallkitIncoming.activeCalls();
|
||||
if (activeCalls.isEmpty) return;
|
||||
|
||||
for (final params in activeCalls) {
|
||||
_cacheCallKitParams(params);
|
||||
if (!params.isAccepted) continue;
|
||||
|
||||
final extra = params.extra ?? <String, dynamic>{};
|
||||
final conversationUuid = _parseConversationUuid(
|
||||
extra,
|
||||
handle: params.handle,
|
||||
);
|
||||
if (conversationUuid.isEmpty) continue;
|
||||
|
||||
await _deliverIncomingAccept(
|
||||
callKitId: params.id,
|
||||
conversationUuid: conversationUuid,
|
||||
counterpartName:
|
||||
_parseString(extra, const [
|
||||
'counterpartName',
|
||||
'caller_name',
|
||||
'callerName',
|
||||
]) ??
|
||||
params.nameCaller,
|
||||
counterpartAvatarUrl:
|
||||
_parseString(extra, const [
|
||||
'counterpartAvatarUrl',
|
||||
'avatar',
|
||||
'avatarUrl',
|
||||
'caller_avatar',
|
||||
]) ??
|
||||
params.avatar,
|
||||
localParticipantName: _parseString(extra, const [
|
||||
'localParticipantName',
|
||||
'local_participant_name',
|
||||
]),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onNativeAcceptCallHandle(Map<dynamic, dynamic> body) async {
|
||||
final extra = Map<String, dynamic>.from(body);
|
||||
final conversationUuid = _parseConversationUuid(extra);
|
||||
@@ -368,6 +317,57 @@ class VideoCallCallKitCoordinator {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleNativeAcceptedVoipCall(Object? arguments) async {
|
||||
if (!Platform.isIOS) return;
|
||||
|
||||
final data = _stringKeyedMap(arguments);
|
||||
final extra = _stringKeyedMap(data['extra']);
|
||||
final callKitId = _parseString(data, const ['id', 'uuid']);
|
||||
if (callKitId == null) {
|
||||
log(
|
||||
'VideoCallCallKitCoordinator: native acceptedVoipCall without callKitId, data=$data',
|
||||
name: 'VideoCallCallKit',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final conversationUuid = _parseConversationUuid(
|
||||
extra,
|
||||
handle: _parseString(data, const ['handle']),
|
||||
);
|
||||
if (conversationUuid.isEmpty) {
|
||||
log(
|
||||
'VideoCallCallKitCoordinator: native acceptedVoipCall without conversationUuid, data=$data',
|
||||
name: 'VideoCallCallKit',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await _deliverIncomingAccept(
|
||||
callKitId: callKitId,
|
||||
conversationUuid: conversationUuid,
|
||||
counterpartName:
|
||||
_parseString(extra, const [
|
||||
'counterpartName',
|
||||
'caller_name',
|
||||
'callerName',
|
||||
]) ??
|
||||
_parseString(data, const ['nameCaller']),
|
||||
counterpartAvatarUrl:
|
||||
_parseString(extra, const [
|
||||
'counterpartAvatarUrl',
|
||||
'avatar',
|
||||
'avatarUrl',
|
||||
'caller_avatar',
|
||||
]) ??
|
||||
_parseString(data, const ['avatar']),
|
||||
localParticipantName: _parseString(extra, const [
|
||||
'localParticipantName',
|
||||
'local_participant_name',
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleAccept(String callKitId) async {
|
||||
if (_acceptHandledCallKitIds.contains(callKitId)) return;
|
||||
|
||||
@@ -387,14 +387,6 @@ class VideoCallCallKitCoordinator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Platform.isIOS) {
|
||||
log(
|
||||
'VideoCallCallKitCoordinator: iOS accept received (keeping CallKit UI), callKitId=$callKitId, conversationUuid=$conversationUuid',
|
||||
name: 'VideoCallCallKit',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await _deliverIncomingAccept(
|
||||
callKitId: callKitId,
|
||||
conversationUuid: conversationUuid,
|
||||
|
||||
Reference in New Issue
Block a user