@@ -51,7 +51,9 @@ final class QRCodeScannerViewController: UIViewController, AVCaptureMetadataOutp
51
51
super. viewWillAppear ( animated)
52
52
53
53
if captureSession. isRunnable {
54
- captureSession. startRunning ( )
54
+ DispatchQueue . global ( qos: . userInitiated) . async { [ weak self] in
55
+ self ? . captureSession. startRunning ( )
56
+ }
55
57
feedback. prepare ( )
56
58
} else {
57
59
let alert = UIAlertController (
@@ -103,11 +105,27 @@ final class QRCodeScannerViewController: UIViewController, AVCaptureMetadataOutp
103
105
104
106
feedback. notificationOccurred ( . success)
105
107
106
- NotificationCenter . default. post (
107
- name: . didReceiveRemoteBundleURL,
108
- object: self ,
109
- userInfo: [ " url " : urlComponents]
110
- )
108
+ guard let presentingViewController = presentingViewController else {
109
+ assertionFailure ( )
110
+ return
111
+ }
112
+
113
+ DispatchQueue . main. async {
114
+ let alert = UIAlertController (
115
+ title: " Is this the right URL? " ,
116
+ message: stringValue,
117
+ preferredStyle: . alert
118
+ )
119
+ alert. addAction ( UIAlertAction . Yes { _ in
120
+ NotificationCenter . default. post (
121
+ name: . didReceiveRemoteBundleURL,
122
+ object: presentingViewController,
123
+ userInfo: [ " url " : urlComponents]
124
+ )
125
+ } )
126
+ alert. addAction ( UIAlertAction . No ( ) )
127
+ presentingViewController. present ( alert, animated: true )
128
+ }
111
129
}
112
130
}
113
131
}
@@ -124,6 +142,26 @@ extension Notification.Name {
124
142
static let didReceiveRemoteBundleURL = Notification . Name ( " didReceiveRemoteBundleURL " )
125
143
}
126
144
145
+ extension UIAlertAction {
146
+ // swiftlint:disable:next identifier_name
147
+ static func No( handler: ( ( UIAlertAction ) -> Void ) ? = nil ) -> UIAlertAction {
148
+ UIAlertAction (
149
+ title: NSLocalizedString ( " No " , comment: " Negative " ) ,
150
+ style: . cancel,
151
+ handler: handler
152
+ )
153
+ }
154
+
155
+ // swiftlint:disable:next identifier_name
156
+ static func Yes( handler: ( ( UIAlertAction ) -> Void ) ? = nil ) -> UIAlertAction {
157
+ UIAlertAction (
158
+ title: NSLocalizedString ( " Yes " , comment: " Affirmative " ) ,
159
+ style: . default,
160
+ handler: handler
161
+ )
162
+ }
163
+ }
164
+
127
165
extension UIDevice {
128
166
var videoOrientation : AVCaptureVideoOrientation {
129
167
switch orientation {
0 commit comments