forked from eatvio/eatvio_app
feat(video_calls): ios call declining notification for other devices fix
This commit is contained in:
@@ -79,6 +79,8 @@ class VideoCallCallKitCoordinator {
|
||||
_scheduleNativeVoipDiagnosticsDrain();
|
||||
case 'acceptedVoipCall':
|
||||
await _handleNativeAcceptedVoipCall(call.arguments);
|
||||
case 'declinedVoipCall':
|
||||
await _handleNativeDeclinedVoipCall(call.arguments);
|
||||
case 'tombstoneCallId':
|
||||
_handleNativeTombstoneCallId(call.arguments);
|
||||
}
|
||||
@@ -390,7 +392,11 @@ class VideoCallCallKitCoordinator {
|
||||
);
|
||||
return;
|
||||
}
|
||||
await _handleDecline(id, eventExtra: _callKitEventParams(event)?.extra);
|
||||
await _handleDecline(
|
||||
id,
|
||||
eventExtra: _callKitEventParams(event)?.extra,
|
||||
skipBackendNotify: Platform.isIOS && event is CallEventActionCallDecline,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleEndedEvent(CallEvent event) async {
|
||||
@@ -615,6 +621,39 @@ class VideoCallCallKitCoordinator {
|
||||
);
|
||||
}
|
||||
|
||||
/// Same payload accept uses. The plugin decline event is not what stops
|
||||
/// ringing on the other devices.
|
||||
Future<void> _handleNativeDeclinedVoipCall(Object? arguments) async {
|
||||
if (!Platform.isIOS) return;
|
||||
|
||||
final data = _stringKeyedMap(arguments);
|
||||
final extra = _stringKeyedMap(data['extra']);
|
||||
if (callKitExtraMarksEndedPush(Map<String, dynamic>.from(extra))) return;
|
||||
|
||||
final callKitId = _parseString(data, const ['id', 'uuid']);
|
||||
if (callKitId != null &&
|
||||
(_suppressedEndCallKitIds.contains(callKitId) ||
|
||||
VideoCallRemoteEndRegistry.contains(callKitId))) {
|
||||
return;
|
||||
}
|
||||
|
||||
final conversationUuid = _parseConversationUuid(
|
||||
extra,
|
||||
handle: _parseString(data, const ['handle']),
|
||||
);
|
||||
final callId = backendVideoCallId(
|
||||
callId:
|
||||
_parseCallId(extra) ??
|
||||
(callKitId != null && callKitId.contains('-') ? callKitId : null),
|
||||
conversationUuid: conversationUuid,
|
||||
);
|
||||
log(
|
||||
'VideoCallCallKitCoordinator: native declinedVoipCall conversation=$conversationUuid callId=$callId',
|
||||
name: 'VideoCallCallKit',
|
||||
);
|
||||
await _manager.declineIncomingCall(conversationUuid, callId: callId);
|
||||
}
|
||||
|
||||
Future<void> _handleAccept(String callKitId) async {
|
||||
if (_acceptNavigationCompletedIds.contains(callKitId)) return;
|
||||
|
||||
@@ -976,6 +1015,7 @@ class VideoCallCallKitCoordinator {
|
||||
Future<void> _handleDecline(
|
||||
String callKitId, {
|
||||
Map<String, dynamic>? eventExtra,
|
||||
bool skipBackendNotify = false,
|
||||
}) async {
|
||||
if (_suppressedEndCallKitIds.contains(callKitId)) {
|
||||
log(
|
||||
@@ -1015,6 +1055,13 @@ class VideoCallCallKitCoordinator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skipBackendNotify) {
|
||||
// iOS decline is reported from AppDelegate with the CallKit payload,
|
||||
// the same way accept is. This plugin event must not send /ended instead.
|
||||
_forgetCallKitId(callKitId);
|
||||
return;
|
||||
}
|
||||
|
||||
_suppressedEndCallKitIds.add(callKitId);
|
||||
try {
|
||||
await FlutterCallkitIncoming.endCall(callKitId);
|
||||
|
||||
Reference in New Issue
Block a user