Skip to content

Commit

Permalink
fix(ios): set camera configuration in main thread (#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Nov 12, 2019
1 parent 52f2bc6 commit c57da0e
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions ios/Capacitor/Capacitor/Plugins/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,26 @@ public class CAPCameraPlugin : CAPPlugin, UIImagePickerControllerDelegate, UINav

AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
let presentationStyle = call.getString("presentationStyle")
if presentationStyle != nil && presentationStyle == "popover" {
self.configurePicker()
} else {
self.imagePicker!.modalPresentationStyle = .fullScreen
}
DispatchQueue.main.async {
let presentationStyle = call.getString("presentationStyle")
if presentationStyle != nil && presentationStyle == "popover" {
self.configurePicker()
} else {
self.imagePicker!.modalPresentationStyle = .fullScreen
}

self.imagePicker!.sourceType = .camera
self.imagePicker!.sourceType = .camera

if self.settings.direction.rawValue == "REAR" {
if UIImagePickerController.isCameraDeviceAvailable(.rear) {
self.imagePicker!.cameraDevice = .rear
}
} else if self.settings.direction.rawValue == "FRONT" {
if UIImagePickerController.isCameraDeviceAvailable(.front) {
self.imagePicker!.cameraDevice = .front
if self.settings.direction.rawValue == "REAR" {
if UIImagePickerController.isCameraDeviceAvailable(.rear) {
self.imagePicker!.cameraDevice = .rear
}
} else if self.settings.direction.rawValue == "FRONT" {
if UIImagePickerController.isCameraDeviceAvailable(.front) {
self.imagePicker!.cameraDevice = .front
}
}
}
DispatchQueue.main.async {

self.bridge.viewController.present(self.imagePicker!, animated: true, completion: nil)
}
} else {
Expand Down

0 comments on commit c57da0e

Please sign in to comment.