From 9c256d45987366b05268b39191beb81de3bf21e6 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 2 Feb 2026 17:43:03 +0200 Subject: [PATCH] Fix call service completion handler calls. (#5026) * Rewrite the CallService's incoming push handling to async * Revert "Rewrite the CallService's incoming push handling to async" * Make sure to call the completion blocks on all branches after delivering incoming pushes Fixes `Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push` crashes Initially tried replacing the callback based API with the async one but notifications stopped coming in. See associated PR for commits and details. --- .../Sources/Services/ElementCall/ElementCallService.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ElementX/Sources/Services/ElementCall/ElementCallService.swift b/ElementX/Sources/Services/ElementCall/ElementCallService.swift index 13935f716..b273dcb22 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallService.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallService.swift @@ -161,16 +161,19 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) { guard let roomID = payload.dictionaryPayload[ElementCallServiceNotificationKey.roomID.rawValue] as? String else { MXLog.error("Something went wrong, missing room identifier for incoming voip call: \(payload)") + completion() return } guard let rtcNotificationID = payload.dictionaryPayload[ElementCallServiceNotificationKey.rtcNotifyEventID.rawValue] as? String else { MXLog.error("Something went wrong, missing rtc notification event identifier for incoming voip call: \(payload)") + completion() return } guard ongoingCallID?.roomID != roomID else { MXLog.warning("Call already ongoing for room \(roomID), ignoring incoming push") + completion() return } @@ -179,6 +182,7 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe guard let expirationDate = (payload.dictionaryPayload[ElementCallServiceNotificationKey.expirationDate.rawValue] as? Date) else { MXLog.error("Something went wrong, missing expiration timestamp for incoming voip call: \(payload)") + completion() return } @@ -186,6 +190,7 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe guard nowDate < expirationDate else { MXLog.warning("Call expired for room \(roomID), ignoring incoming push") + completion() return }