diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 6b57e9ec1..3146d52b8 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -320,14 +320,29 @@ final class CallVC : UIViewController, WebRTCSessionDelegate, VideoPreviewDelega } } + internal func showCallModal() { + let callModal = CallModal() { [weak self] in + self?.answerCall() + } + callModal.modalPresentationStyle = .overFullScreen + callModal.modalTransitionStyle = .crossDissolve + present(callModal, animated: true, completion: nil) + } + @objc private func answerCall() { - if case let .answer(sdp) = mode { - callInfoLabel.text = "Connecting..." - webRTCSession.handleRemoteSDP(sdp, from: sessionID) // This sends an answer message internally - self.answerButton.alpha = 0 - UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseIn, animations: { - self.answerButton.isHidden = true - }, completion: nil) + let userDefaults = UserDefaults.standard + if userDefaults[.hasSeenCallIPExposureWarning] { + if case let .answer(sdp) = mode { + callInfoLabel.text = "Connecting..." + webRTCSession.handleRemoteSDP(sdp, from: sessionID) // This sends an answer message internally + self.answerButton.alpha = 0 + UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseIn, animations: { + self.answerButton.isHidden = true + }, completion: nil) + } + } else { + userDefaults[.hasSeenCallIPExposureWarning] = true + showCallModal() } } diff --git a/Session/Calls/Views & Modals/IncomingCallBanner.swift b/Session/Calls/Views & Modals/IncomingCallBanner.swift index 8ec49aadd..6db4a50b3 100644 --- a/Session/Calls/Views & Modals/IncomingCallBanner.swift +++ b/Session/Calls/Views & Modals/IncomingCallBanner.swift @@ -140,7 +140,22 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate { } @objc private func answerCall() { - showCallVC(answer: true) + let userDefaults = UserDefaults.standard + if userDefaults[.hasSeenCallIPExposureWarning] { + showCallVC(answer: true) + } else { + showCallModal() + } + } + + internal func showCallModal() { + let callModal = CallModal() { [weak self] in + self?.showCallVC(answer: true) + } + callModal.modalPresentationStyle = .overFullScreen + callModal.modalTransitionStyle = .crossDissolve + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + presentingVC.present(callModal, animated: true, completion: nil) } @objc private func endCall() { diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index a35a20db6..d4071501c 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -28,14 +28,20 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc // MARK: Call @objc func startCall(_ sender: Any?) { - guard let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return } - let callVC = CallVC(for: contactSessionID, uuid: UUID().uuidString, mode: .offer) - callVC.conversationVC = self - callVC.modalPresentationStyle = .overFullScreen - callVC.modalTransitionStyle = .crossDissolve - self.inputAccessoryView?.isHidden = true - self.inputAccessoryView?.alpha = 0 - present(callVC, animated: true, completion: nil) + let userDefaults = UserDefaults.standard + if userDefaults[.hasSeenCallIPExposureWarning] { + guard let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return } + let callVC = CallVC(for: contactSessionID, uuid: UUID().uuidString, mode: .offer) + callVC.conversationVC = self + callVC.modalPresentationStyle = .overFullScreen + callVC.modalTransitionStyle = .crossDissolve + self.inputAccessoryView?.isHidden = true + self.inputAccessoryView?.alpha = 0 + present(callVC, animated: true, completion: nil) + } else { + userDefaults[.hasSeenCallIPExposureWarning] = true + showCallModal() + } } internal func showCallModal() { diff --git a/SessionUtilitiesKit/General/SNUserDefaults.swift b/SessionUtilitiesKit/General/SNUserDefaults.swift index 8a0fad35b..99065af49 100644 --- a/SessionUtilitiesKit/General/SNUserDefaults.swift +++ b/SessionUtilitiesKit/General/SNUserDefaults.swift @@ -6,6 +6,7 @@ public enum SNUserDefaults { case hasSyncedInitialConfiguration = "hasSyncedConfiguration" case hasViewedSeed case hasSeenLinkPreviewSuggestion + case hasSeenCallIPExposureWarning case isUsingFullAPNs }