diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index cda7cb539..482344033 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -12,6 +12,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate { var shouldAnswer = false var isMuted = false var isVideoEnabled = false + var shouldRestartCamera = true var conversationVC: ConversationVC? = nil lazy var cameraManager: CameraManager = { @@ -181,7 +182,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate { view.backgroundColor = .black WebRTCSession.current = webRTCSession setUpViewHierarchy() - cameraManager.prepare() + if shouldRestartCamera { cameraManager.prepare() } touch(videoCapturer) var contact: Contact? Storage.read { transaction in @@ -192,9 +193,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate { callInfoLabel.text = "Ringing..." Storage.write { transaction in self.webRTCSession.sendPreOffer(to: self.sessionID, using: transaction).done { - self.webRTCSession.sendOffer(to: self.sessionID, using: transaction).done { - self.minimizeButton.isHidden = false - }.retainUntilComplete() + self.webRTCSession.sendOffer(to: self.sessionID, using: transaction).retainUntilComplete() }.retainUntilComplete() } answerButton.isHidden = true @@ -272,18 +271,20 @@ final class CallVC : UIViewController, WebRTCSessionDelegate { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - if (isVideoEnabled) { cameraManager.start() } + if (isVideoEnabled && shouldRestartCamera) { cameraManager.start() } + shouldRestartCamera = true } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - if (isVideoEnabled) { cameraManager.stop() } + if (isVideoEnabled && shouldRestartCamera) { cameraManager.stop() } } // MARK: Delegate func webRTCIsConnected() { DispatchQueue.main.async { self.callInfoLabel.text = "Connected" + self.minimizeButton.isHidden = false UIView.animate(withDuration: 0.5, delay: 1, options: [], animations: { self.callInfoLabel.alpha = 0 }, completion: { _ in @@ -339,6 +340,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate { } @objc private func minimize() { + self.shouldRestartCamera = false let miniCallView = MiniCallView(from: self) miniCallView.show() self.conversationVC?.showInputAccessoryView() diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index b4eb44d02..930b7b68f 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -216,14 +216,6 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension private func handleSuccessForIncomingCall(for content: UNMutableNotificationContent) { // TODO: poll for the real offer, play incoming call ring - if #available(iOSApplicationExtension 13.0, *) { - let request = BGAppRefreshTaskRequest(identifier: "com.loki-project.loki-messenger.refresh") - do { - try BGTaskScheduler.shared.submit(request) - } catch { - print("Could not schedule app refresh: \(error)") - } - } contentHandler!(content) } diff --git a/SessionUtilitiesKit/General/Vibration.swift b/SessionUtilitiesKit/General/Vibration.swift index 479e1ba3f..4e9aa2e6f 100644 --- a/SessionUtilitiesKit/General/Vibration.swift +++ b/SessionUtilitiesKit/General/Vibration.swift @@ -7,7 +7,7 @@ public final class Vibration { private var vibrationTimer: Timer? public func startVibration() { - vibrationTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in + vibrationTimer = Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { _ in AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) } }