diff --git a/Session/Calls/Call Management/SessionCall.swift b/Session/Calls/Call Management/SessionCall.swift index 007941b69..036825a4d 100644 --- a/Session/Calls/Call Management/SessionCall.swift +++ b/Session/Calls/Call Management/SessionCall.swift @@ -27,7 +27,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { let isOutgoing: Bool var remoteSDP: RTCSessionDescription? = nil var callInteractionId: Int64? - var answerCallAction: CXAnswerCallAction? = nil let contactName: String let profilePicture: UIImage @@ -268,12 +267,15 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { hasStartedConnecting = true if let sdp = remoteSDP { + SNLog("[Calls] Got remote sdp already") webRTCSession.handleRemoteSDP(sdp, from: sessionId) // This sends an answer message internally + } else { + SNLog("[Calls] Didn't get remote sdp yet, waiting for it") } } - func answerSessionCallInBackground(action: CXAnswerCallAction) { - answerCallAction = action + func answerSessionCallInBackground() { + SNLog("[Calls] Answering call in background") self.answerSessionCall() } @@ -394,7 +396,6 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { } self.hasConnected = true - self.answerCallAction?.fulfill() } public func isRemoteVideoDidChange(isEnabled: Bool) { diff --git a/Session/Calls/Call Management/SessionCallManager+CXProvider.swift b/Session/Calls/Call Management/SessionCallManager+CXProvider.swift index af8536619..ce1af876e 100644 --- a/Session/Calls/Call Management/SessionCallManager+CXProvider.swift +++ b/Session/Calls/Call Management/SessionCallManager+CXProvider.swift @@ -23,9 +23,12 @@ extension SessionCallManager: CXProviderDelegate { public func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { Log.assertOnMainThread() - Log.debug("[CallKit] Perform CXAnswerCallAction") + Log.info("[CallKit] Perform CXAnswerCallAction") - guard let call: SessionCall = (self.currentCall as? SessionCall) else { return action.fail() } + guard let call: SessionCall = (self.currentCall as? SessionCall) else { + Log.warn("[CallKit] No session call") + return action.fail() + } if Singleton.hasAppContext && Singleton.appContext.isMainAppAndActive { if answerCallAction() { @@ -36,7 +39,8 @@ extension SessionCallManager: CXProviderDelegate { } } else { - call.answerSessionCallInBackground(action: action) + call.answerSessionCallInBackground() + action.fulfill() } }