fix: Fix mapping of itf and add new itf-14 type in iOS
What
I can't scan interleaved2of5 (ITF) barcodes in iOS.
Currently the CodeType itf is mapped:
- on android to
Barcode.FORMAT_ITF, which is the "barcode format constant for ITF (Interleaved Two-of-Five)" - on iOS to
AVMetadataObject.ObjectType.itf14, which is "a constant that identifies the ITF14 symbology"
ITF-14 is a variant of ITF with a fixed length of 14 characters. The problem is that the iOS AVMetadataObject.ObjectType.interleaved2of5 type is not mapped at all and therefore interleaved2of5 barcodes with a different length than 14 characters cannot be scanned in iOS.
Changes
Added and changed the mapping for iOS:
- itf -> interleaved2of5
- new itf-14 -> itf14 (iOS only)
Updated documentation about code types.
If you add now itf-14 unconditionally (i.e. don't exclude it for android) to the codeTypes array of the CodeScanner, in android it will (expectedly) throw the error "The given value for codeType could not be parsed! (Received: itf-14)".
Tested on
- iPhone 12 mini, iOS 18.1
- Google Pixel 7, Android 15
Related issues
- fixes #2089
- fixes #2064
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-native-vision-camera | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 19, 2024 6:18pm |
Awesome!! Nice high quality PR, thanks for the fix and thanks for the explanation. LGTM! ❤️