fix CallKit failed to report new incoming calls in focus mode

pull/562/head
Ryan Zhao 2 years ago
parent 54493e56ef
commit f7af8141c0

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

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

Loading…
Cancel
Save