diff --git a/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift b/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift index c2ba75927f..7a1b730c1f 100644 --- a/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift +++ b/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift @@ -130,6 +130,13 @@ class PhotoCaptureViewController: OWSViewController, OWSNavigationChildControlle cameraCaptureSession.updateVideoPreviewConnection(toOrientation: previewOrientation) updateIconOrientations(isAnimated: false, captureOrientation: previewOrientation) + NotificationCenter.default.addObserver( + self, + selector: #selector(sessionWasInterrupted), + name: AVCaptureSession.wasInterruptedNotification, + object: nil + ) + resumePhotoCapture() if let dataSource = dataSource, dataSource.numberOfMediaItems > 0 { @@ -1520,6 +1527,18 @@ extension PhotoCaptureViewController: CameraCaptureSessionDelegate { func cameraCaptureSession(_ session: CameraCaptureSession, didFinishFocusingAt focusPoint: CGPoint) { completeFocusAnimation(forFocusPoint: focusPoint) } + + @objc + func sessionWasInterrupted(notification: Notification) { + if let userInfo = notification.userInfo { + guard let reasonValue = userInfo[AVCaptureSessionInterruptionReasonKey] as? NSNumber, + let reason = AVCaptureSession.InterruptionReason(rawValue: reasonValue.intValue) else { + Logger.info("session was interrupted for no apparent reason") + return + } + Logger.info("session was interrupted with reason code: \(reason.rawValue)") + } + } } private protocol TextStoryComposerViewDelegate: AnyObject {