Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto) - error while open camera iOS swift

 Problem:

While try to open camera in my app it shows that below error.

Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto

.. How to solve that?

Solution:

Because you tried in main queue.You must  try async then it will be solved.
My function to be as like below.

    func openCamera() {

        let authStatus = AVCaptureDevice.authorizationStatus(forAVMediaType.video)

        switch (authStatus){

        case .notDetermined:

            showAlert(msg:"Camera access denied"controllerself)

        case .restricted:

            showAlert(msg"Camera access denied"controllerself)

        case .denied:

            showAlert(msg"Camera access denied"controllerself)

        case .authorized:

            if getCameraAccess() == true{

                DispatchQueue.main.async() {

                    

                    if(UIImagePickerController .isSourceTypeAvailable(UIImagePickerController.SourceType.camera)) {

                        self.imagePickerController.sourceType = .camera

                        self.imagePickerController.delegate = self

                        self.imagePickerController.mediaTypes = [kUTTypeMovie as StringkUTTypeImage as String]

                        self.present(self.imagePickerControlleranimatedtruecompletionnil)

                        

                    }

                }

            }

            else{

                showAlert(msg"Camera access denied"controllerself)

            }

        @unknown default:

            break

        }

    }


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift