Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): set camera configuration in main thread #2167

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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