Require video for callkit even if voice call only to workaround a bug answering calls on the lock screen (#5366)

This commit is contained in:
Valere Fedronic
2026-04-09 16:18:06 +02:00
committed by GitHub
parent 1a5a709e27
commit 7434d531b2
2 changed files with 8 additions and 2 deletions
@@ -202,7 +202,11 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
let roomDisplayName = payload.dictionaryPayload[ElementCallServiceNotificationKey.roomDisplayName.rawValue] as? String let roomDisplayName = payload.dictionaryPayload[ElementCallServiceNotificationKey.roomDisplayName.rawValue] as? String
let update = CXCallUpdate() 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 update.localizedCallerName = roomDisplayName
// https://stackoverflow.com/a/41230020/730924 // https://stackoverflow.com/a/41230020/730924
update.remoteHandle = .init(type: .generic, value: roomID) update.remoteHandle = .init(type: .generic, value: roomID)
@@ -73,7 +73,9 @@ final class ElementCallServiceTests {
#expect(callProvider.reportNewIncomingCallWithUpdateCompletionCalled) #expect(callProvider.reportNewIncomingCallWithUpdateCompletionCalled)
// Verify the provider was called with a CXCallUpdate that has video enabled // Verify the provider was called with a CXCallUpdate that has video enabled
if let args = callProvider.reportNewIncomingCallWithUpdateCompletionReceivedArguments { 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 { } else {
Issue.record("Expected reportNewIncomingCallWithUpdateCompletionReceivedArguments to be captured") Issue.record("Expected reportNewIncomingCallWithUpdateCompletionReceivedArguments to be captured")
} }