Skip to content

Commit

Permalink
Merge pull request #452 from juliuscanute/bug-ios-11-raw-bytes
Browse files Browse the repository at this point in the history
bug: fix crash because of unsupported iOS version
  • Loading branch information
juliansteenbakker authored Nov 3, 2021
2 parents 0935a4d + f71f384 commit f4bfabe
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ios/Classes/QRView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,20 @@ public class QRView:NSObject,FlutterPlatformView {
return
}
let bytes = { () -> Data? in
switch (code.descriptor) {
case let qrDescriptor as CIQRCodeDescriptor:
return qrDescriptor.errorCorrectedPayload
case let aztecDescriptor as CIAztecCodeDescriptor:
return aztecDescriptor.errorCorrectedPayload
case let pdf417Descriptor as CIPDF417CodeDescriptor:
return pdf417Descriptor.errorCorrectedPayload
case let dataMatrixDescriptor as CIDataMatrixCodeDescriptor:
return dataMatrixDescriptor.errorCorrectedPayload
default:
if #available(iOS 11.0, *) {
switch (code.descriptor) {
case let qrDescriptor as CIQRCodeDescriptor:
return qrDescriptor.errorCorrectedPayload
case let aztecDescriptor as CIAztecCodeDescriptor:
return aztecDescriptor.errorCorrectedPayload
case let pdf417Descriptor as CIPDF417CodeDescriptor:
return pdf417Descriptor.errorCorrectedPayload
case let dataMatrixDescriptor as CIDataMatrixCodeDescriptor:
return dataMatrixDescriptor.errorCorrectedPayload
default:
return nil
}
} else {
return nil
}
}()
Expand All @@ -190,7 +194,7 @@ public class QRView:NSObject,FlutterPlatformView {
}
return ["code": stringValue, "type": typeString, "rawBytes": safeBytes]
}()
guard let safeResult = result else { continue }
guard result != nil else { continue }
if allowedBarcodeTypes.count == 0 || allowedBarcodeTypes.contains(code.type) {
self?.channel.invokeMethod("onRecognizeQR", arguments: result)
}
Expand Down

0 comments on commit f4bfabe

Please sign in to comment.