Open jjsebastianfuertes opened 3 years ago
@jjsebastianfuertes Have the same problem! any updates on this?
Is it safe to assume that ios always returns a leading zero?
any updates on this? @AmolGangadhare
Facing the same problem here. Thanks for any update on the issue ;-). Nice package.
this is not from the library but from ios. of course library should handle it. i corrected it myself.
apple explanation
UPC-A is a formal subset of EAN-13. A decoded UPC-A barcode is output as AVMetadataObjectTypeEAN13Code with a leading zero in the stringValue.
you need to change below function inside
SwiftFlutterBarcodeScannerPlugin.swift -> BarcodeScannerViewController -> metadataOutput
if metadataObj.stringValue != nil {
if(SwiftFlutterBarcodeScannerPlugin.isContinuousScan){
SwiftFlutterBarcodeScannerPlugin.onBarcodeScanReceiver(barcode: metadataObj.stringValue!)
}else{
launchApp(decodedURL: metadataObj.stringValue!)
}
}
to this one
var code = metadataObj.stringValue
if code != nil {
if metadataObj.type == AVMetadataObject.ObjectType.ean13 && code!.hasPrefix("0") {
code = String(code!.dropFirst())
}
if(SwiftFlutterBarcodeScannerPlugin.isContinuousScan){
SwiftFlutterBarcodeScannerPlugin.onBarcodeScanReceiver(barcode: code!)
}else{
launchApp(decodedURL: code!)
}
}
Describe the bug scanning UPC BARCODE on iOS device returns the number but with a zero at the beginning. It should return only the number without the zero.
To Reproduce Steps to reproduce the behavior:
Expected behavior the code returned should be the one on the BARCODE without implementing a zero at the beginning. This behaivor only happens on iOS
SCREENSHOTS
Smartphone: