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.
This commit is contained in:
Stefan Ceriu
2026-02-02 17:43:03 +02:00
committed by GitHub
parent 53e1cf4ad5
commit 9c256d4598

View File

@@ -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
}