How to use AVCaptureSession with Slide Over and Split View in iOS 9?
In case you haven't found out yet. After some more investigation I can now answer your first question:
If AVCaptureSession is immediately paused when Slide Over and Split View are used, is it a good idea to monitor AVCaptureSessionDidStopRunningNotification, and present a message "Camera Paused" to the user, so that he clearly knows that the app isn't performing scanning?
The notification you actually want to observe is this one: AVCaptureSessionWasInterruptedNotification
And you want to check for the newly introduced in iOS9 reason: AVCaptureSessionInterruptionReason.VideoDeviceNotAvailableWithMultipleForegroundApps
override func viewWillAppear(animated: Bool){ super.viewWillAppear(animated) self.addObserverForAVCaptureSessionWasInterrupted()}func addObserverForAVCaptureSessionWasInterrupted(){ let mainQueue = NSOperationQueue.mainQueue() NSNotificationCenter.defaultCenter().addObserverForName(AVCaptureSessionWasInterruptedNotification, object: nil, queue: mainQueue) { (notification: NSNotification) -> Void in guard let userInfo = notification.userInfo else { return } // Check if the current system is iOS9+ because AVCaptureSessionInterruptionReasonKey is iOS9+ (relates to Split View / Slide Over) if #available(iOS 9.0, *) { if let interruptionReason = userInfo[AVCaptureSessionInterruptionReasonKey] where Int(interruptionReason as! NSNumber) == AVCaptureSessionInterruptionReason.VideoDeviceNotAvailableWithMultipleForegroundApps.rawValue { // Warn the user they need to get back to Full Screen Mode } } else { // Fallback on earlier versions. From iOS8 and below Split View and Slide Over don't exist, no need to handle anything then. } }}override func viewWillDisappear(animated: Bool){ super.viewWillDisappear(true) NSNotificationCenter.defaultCenter().removeObserver(self)}
You can also know when the interruption was ended by observing:AVCaptureSessionInterruptionEndedNotification
Answer based on these two links:
http://asciiwwdc.com/2015/sessions/211https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html