diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index 7fd66e7d5..91cb26a01 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -92,7 +92,7 @@ public final class SessionCallManager: NSObject { // Report the incoming call to the system self.provider.reportNewIncomingCall(with: call.callID, update: update) { error in guard error == nil else { - self.currentCall = nil + self.reportCurrentCallEnded(reason: .failed) completion(error) Logger.error("failed to report new incoming call, error: \(error!)") return diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 59ec4e3ca..e9d1d3529 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -28,21 +28,20 @@ extension AppDelegate { private func showCallUIForCall(_ call: SessionCall) { DispatchQueue.main.async { - if CurrentAppContext().isMainAppAndActive { - guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully - if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == call.sessionID { - let callVC = CallVC(for: call) - callVC.conversationVC = conversationVC - conversationVC.inputAccessoryView?.isHidden = true - conversationVC.inputAccessoryView?.alpha = 0 - presentingVC.present(callVC, animated: true, completion: nil) - } - } call.reportIncomingCallIfNeeded{ error in if let error = error { SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)") - let incomingCallBanner = IncomingCallBanner(for: call) - incomingCallBanner.show() + } else { + if CurrentAppContext().isMainAppAndActive { + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == call.sessionID { + let callVC = CallVC(for: call) + callVC.conversationVC = conversationVC + conversationVC.inputAccessoryView?.isHidden = true + conversationVC.inputAccessoryView?.alpha = 0 + presentingVC.present(callVC, animated: true, completion: nil) + } + } } } }