Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if iPhone has dual camera?

Tags:

ios

swift

I'm writing a photo app and I need different overlays in the camera view for iPhones with dual camera (to account for the zoom ui), is there a proper way to check if a dual camera exists?

I tried to get the device and check if it was nil for the non dual camera iPhones, tho it still retunes a device:

let device = AVCaptureDevice.defaultDevice(withDeviceType: .builtInDualCamera, mediaType: AVMediaTypeVideo, position: .back)

Dose anyone know how to detect the dual camera?

like image 518
Heestand XYZ Avatar asked Jul 01 '17 20:07

Heestand XYZ


Video Answer


1 Answers

Swift 5:

var currentDevice:AVCaptureDevice?

     if let device = AVCaptureDevice.default(.builtInDualCamera, for: AVMediaType.video, position: .back) {

                currentDevice = device

         } else if let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back) {

                currentDevice = device

            } else {

                print("Error: no camera available")
            }
like image 164
CarlosBF Avatar answered Sep 29 '22 01:09

CarlosBF