Explorar el Código

run camera permission completion handler code on UI thread

cyberta hace 3 años
padre
commit
377eb88caf
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  1. 7 5
      deltachat-ios/Controller/QrCodeReaderController.swift

+ 7 - 5
deltachat-ios/Controller/QrCodeReaderController.swift

@@ -46,11 +46,13 @@ class QrCodeReaderController: UIViewController {
         } else {
             AVCaptureDevice.requestAccess(for: .video, completionHandler: {  [weak self] (granted: Bool) in
                 guard let self = self else { return }
-                if granted {
-                    self.setupQRCodeScanner()
-                } else {
-                    self.showCameraWarning()
-                    self.showPermissionAlert()
+                DispatchQueue.main.async {
+                    if granted {
+                        self.setupQRCodeScanner()
+                    } else {
+                        self.showCameraWarning()
+                        self.showPermissionAlert()
+                    }
                 }
             })
         }