diff --git a/Session/Notifications/PushRegistrationManager.swift b/Session/Notifications/PushRegistrationManager.swift index fe47fdf7e..0fe999ffb 100644 --- a/Session/Notifications/PushRegistrationManager.swift +++ b/Session/Notifications/PushRegistrationManager.swift @@ -236,15 +236,17 @@ public enum PushRegistrationError: Error { } public func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) { + SNLog("[Calls] Receive new voip notification.") owsAssertDebug(CurrentAppContext().isMainApp) owsAssertDebug(type == .voIP) let payload = payload.dictionaryPayload if let uuid = payload["uuid"] as? String, let caller = payload["caller"] as? String { - let appDelegate = UIApplication.shared.delegate as! AppDelegate - appDelegate.createNewIncomingCall(caller: caller, uuid: uuid) - appDelegate.startPollerIfNeeded() - appDelegate.startClosedGroupPoller() - appDelegate.startOpenGroupPollersIfNeeded() + let call = SessionCall(for: caller, uuid: uuid, mode: .answer) + call.reportIncomingCallIfNeeded { error in + if let error = error { + SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)") + } + } } } } diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index 736bd7c82..a861eacce 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -220,17 +220,19 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension if #available(iOSApplicationExtension 14.5, *) { if let uuid = callMessage.uuid, let caller = callMessage.sender { let payload = ["uuid": uuid, "caller": caller] - return CXProvider.reportNewIncomingVoIPPushPayload(payload) { error in + CXProvider.reportNewIncomingVoIPPushPayload(payload) { error in if let error = error { + self.contentHandler!(content) owsFailDebug("Failed to notify main app of call message: \(error)") } else { + self.completeSilenty() Logger.info("Successfully notified main app of call message.") } - self.completeSilenty() } } + } else { + self.contentHandler!(content) } - self.contentHandler!(content) } private func handleSuccess(for content: UNMutableNotificationContent) {