From 7434d531b22de150f646655332d0c97b238fb823 Mon Sep 17 00:00:00 2001 From: Valere Fedronic Date: Thu, 9 Apr 2026 16:18:06 +0200 Subject: [PATCH] Require video for callkit even if voice call only to workaround a bug answering calls on the lock screen (#5366) --- .../Sources/Services/ElementCall/ElementCallService.swift | 6 +++++- UnitTests/Sources/ElementCallServiceTests.swift | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ElementX/Sources/Services/ElementCall/ElementCallService.swift b/ElementX/Sources/Services/ElementCall/ElementCallService.swift index 2512e1674..7e01ac4f0 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallService.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallService.swift @@ -202,7 +202,11 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe let roomDisplayName = payload.dictionaryPayload[ElementCallServiceNotificationKey.roomDisplayName.rawValue] as? String let update = CXCallUpdate() - update.hasVideo = !isVoiceCall + // Work Around: Always set video to true! https://github.com/element-hq/element-x-ios/issues/5335 + // If not for audio call the app will not be put to foreground and the webview won't be able to handle the call... + // Consequence: The call will be presented to the user as a video call in CallKit UI, + // but once Element Call is launched it will correctly route to a voice-only call. + update.hasVideo = true update.localizedCallerName = roomDisplayName // https://stackoverflow.com/a/41230020/730924 update.remoteHandle = .init(type: .generic, value: roomID) diff --git a/UnitTests/Sources/ElementCallServiceTests.swift b/UnitTests/Sources/ElementCallServiceTests.swift index 14d910f53..72d49bec3 100644 --- a/UnitTests/Sources/ElementCallServiceTests.swift +++ b/UnitTests/Sources/ElementCallServiceTests.swift @@ -73,7 +73,9 @@ final class ElementCallServiceTests { #expect(callProvider.reportNewIncomingCallWithUpdateCompletionCalled) // Verify the provider was called with a CXCallUpdate that has video enabled if let args = callProvider.reportNewIncomingCallWithUpdateCompletionReceivedArguments { - #expect(args.update.hasVideo == false) + // Due to a limitation on Callkit and Webviews, we currently have to report voice calls as having video, + // even if they are voice calls :/ If not the webview is not started and the call is not shown to the user. + #expect(args.update.hasVideo == true) } else { Issue.record("Expected reportNewIncomingCallWithUpdateCompletionReceivedArguments to be captured") }