fix CallKit failed to report new incoming calls in focus mode

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

@ -92,7 +92,7 @@ public final class SessionCallManager: NSObject {
// Report the incoming call to the system // Report the incoming call to the system
self.provider.reportNewIncomingCall(with: call.callID, update: update) { error in self.provider.reportNewIncomingCall(with: call.callID, update: update) { error in
guard error == nil else { guard error == nil else {
self.currentCall = nil self.reportCurrentCallEnded(reason: .failed)
completion(error) completion(error)
Logger.error("failed to report new incoming call, error: \(error!)") Logger.error("failed to report new incoming call, error: \(error!)")
return return

@ -28,6 +28,10 @@ extension AppDelegate {
private func showCallUIForCall(_ call: SessionCall) { private func showCallUIForCall(_ call: SessionCall) {
DispatchQueue.main.async { DispatchQueue.main.async {
call.reportIncomingCallIfNeeded{ error in
if let error = error {
SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)")
} else {
if CurrentAppContext().isMainAppAndActive { if CurrentAppContext().isMainAppAndActive {
guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully 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 { if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == call.sessionID {
@ -38,11 +42,6 @@ extension AppDelegate {
presentingVC.present(callVC, animated: true, completion: nil) 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()
} }
} }
} }

Loading…
Cancel
Save