fix call connection

pull/560/head
ryanzhao 4 years ago
parent bef20e2f9a
commit 888df37581

@ -125,6 +125,7 @@ public final class SessionCall: NSObject, WebRTCSessionDelegate {
self.uuid = UUID(uuidString: uuid)! self.uuid = UUID(uuidString: uuid)!
self.mode = mode self.mode = mode
self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionID, with: uuid) self.webRTCSession = WebRTCSession.current ?? WebRTCSession(for: sessionID, with: uuid)
WebRTCSession.current = self.webRTCSession
super.init() super.init()
self.webRTCSession.delegate = self self.webRTCSession.delegate = self
} }

@ -62,7 +62,7 @@ public final class SessionCallManager: NSObject {
let update = CXCallUpdate() let update = CXCallUpdate()
update.localizedCallerName = callerName update.localizedCallerName = callerName
update.remoteHandle = CXHandle(type: .generic, value: call.uuid.uuidString) update.remoteHandle = CXHandle(type: .generic, value: call.uuid.uuidString)
update.hasVideo = true update.hasVideo = false
disableUnsupportedFeatures(callUpdate: update) disableUnsupportedFeatures(callUpdate: update)

@ -7,25 +7,25 @@ extension AppDelegate {
// MARK: Call handling // MARK: Call handling
func createNewIncomingCall(caller: String, uuid: String) { func createNewIncomingCall(caller: String, uuid: String) {
let call = SessionCall(for: caller, uuid: uuid, mode: .answer) DispatchQueue.main.async {
if CurrentAppContext().isMainAppAndActive { let call = SessionCall(for: caller, uuid: uuid, mode: .answer)
guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully if CurrentAppContext().isMainAppAndActive {
if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == caller { guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully
DispatchQueue.main.async { if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == caller {
let callVC = CallVC(for: call) let callVC = CallVC(for: call)
callVC.conversationVC = conversationVC callVC.conversationVC = conversationVC
conversationVC.inputAccessoryView?.isHidden = true conversationVC.inputAccessoryView?.isHidden = true
conversationVC.inputAccessoryView?.alpha = 0 conversationVC.inputAccessoryView?.alpha = 0
presentingVC.present(callVC, animated: true, completion: nil) presentingVC.present(callVC, animated: true, completion: nil)
return
} }
return
} }
} call.reportIncomingCallIfNeeded{ error in
call.reportIncomingCallIfNeeded{ error in if let error = error {
if let error = error { SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)")
SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)") let incomingCallBanner = IncomingCallBanner(for: call)
let incomingCallBanner = IncomingCallBanner(for: call) incomingCallBanner.show()
incomingCallBanner.show() }
} }
} }
} }

Loading…
Cancel
Save