Skip to content

Commit e3de532

Browse files
feat: Use hint and return barcode format (#86)
Co-authored-by: Alexandre Jacinto <[email protected]>
1 parent 29f0def commit e3de532

27 files changed

+6667
-5172
lines changed

.github/workflows/basic-tests.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,40 @@ jobs:
1616

1717
build-packages:
1818
needs: 'setup'
19-
uses: ./.github/workflows/reusable_build-packages.yml
19+
uses: ./.github/workflows/reusable_build-packages.yml
20+
21+
verify-plugin:
22+
needs: ['setup', 'lint-test', 'build-packages']
23+
runs-on: 'macos-14'
24+
timeout-minutes: 30
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: 'Setup Tools'
28+
uses: ./.github/actions/setup-tools
29+
- name: 'Verify iOS + Android + Web'
30+
working-directory: ./plugin
31+
run: npm run verify
32+
33+
build-example-app:
34+
needs: ['verify-plugin']
35+
runs-on: 'macos-14'
36+
timeout-minutes: 30
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: 'Setup Tools'
40+
uses: ./.github/actions/setup-tools
41+
- name: 'Build plugin'
42+
working-directory: ./plugin
43+
run: npm run build
44+
- name: 'Build Web example app'
45+
working-directory: ./example-app
46+
run: npm run build
47+
- name: 'Sync example app native platforms'
48+
working-directory: ./example-app
49+
run: npx cap sync
50+
- name: 'Build Android example app'
51+
working-directory: ./example-app/android
52+
run: ./gradlew clean assembleDebug
53+
- name: 'Build iOS example app'
54+
working-directory: ./example-app/ios/App
55+
run: xcodebuild clean build -workspace App.xcworkspace -scheme App CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

.github/workflows/reusable_lint-packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
lint:
11-
runs-on: 'macos-13'
11+
runs-on: 'macos-14'
1212
timeout-minutes: 30
1313
steps:
1414
- uses: actions/checkout@v3

.github/workflows/reusable_setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
setup:
1111
strategy:
1212
matrix:
13-
os: ['ubuntu-22.04', 'macos-13']
13+
os: ['ubuntu-22.04', 'macos-14']
1414
runs-on: ${{ matrix.os }}
1515
timeout-minutes: 30
1616
steps:

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
55

66
## [2.0.4](https://github.com/ionic-team/capacitor-barcode-scanner/compare/v2.0.3...v2.0.4) (2025-08-20)
77

8-
**Note:** Version bump only for package root
8+
### Performance improvements
99

10+
* (android) Reduce memory consumption for ML Kit ([#82](https://github.com/ionic-team/capacitor-barcode-scanner/pull/82))
1011

1112

1213

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ ext {
1919
}
2020
```
2121

22+
Note: Android with `ZXING` scanning library supports all formats, while `MLKIT` supports all except `MAXICODE`, `RSS_14`, `RSS_EXPANDED` and `UPC_EAN_EXTENSION` - using one of these in `hint` will default to scanning any format.
23+
2224
#### iOS
2325

2426
The barcode scanner uses the camera on the device. Ensure you configure the Privacy - Camera Usage Description in your Info.plist file so that your application can access the device's camera.
2527

28+
Note: iOS supports all formats except `MAXICODE` and `UPC_EAN_EXTENSION` - using them in `hint` will default to scanning any format. Also, Apple Vision does not distinguish between `UPC_A` and `EAN_13`, so specifying one of these in `hint` will allow to scan both.
29+
2630
---
2731

2832
## API
@@ -63,14 +67,7 @@ scanBarcode(options: CapacitorBarcodeScannerOptions) => Promise<CapacitorBarcode
6367

6468
Defines the structure of the result returned from a barcode scan.
6569

66-
<code>{ ScanResult: string }</code>
67-
68-
69-
#### CapacitorBarcodeScannerOptions
70-
71-
Defines the options for configuring a barcode scan.
72-
73-
<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>; scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>; android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; }</code>
70+
<code>{ ScanResult: string; format: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; }</code>
7471

7572

7673
#### CapacitorBarcodeScannerTypeHint
@@ -83,6 +80,13 @@ to represent the hint for the type of barcode to be scanned.
8380
<code><a href="#html5qrcodesupportedformats">Html5QrcodeSupportedFormats</a> | <a href="#capacitorbarcodescannertypehintalloption">CapacitorBarcodeScannerTypeHintALLOption</a></code>
8481

8582

83+
#### CapacitorBarcodeScannerOptions
84+
85+
Defines the options for configuring a barcode scan.
86+
87+
<code>{ hint: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: <a href="#capacitorbarcodescannercameradirection">CapacitorBarcodeScannerCameraDirection</a>; scanOrientation?: <a href="#capacitorbarcodescannerscanorientation">CapacitorBarcodeScannerScanOrientation</a>; android?: { scanningLibrary?: <a href="#capacitorbarcodescannerandroidscanninglibrary">CapacitorBarcodeScannerAndroidScanningLibrary</a>; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; }</code>
88+
89+
8690
### Enums
8791

8892

example-app/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
55

66
## [2.0.4](https://github.com/ionic-team/capacitor-barcode-scanner/compare/v2.0.3...v2.0.4) (2025-08-20)
77

8-
**Note:** Version bump only for package example-app
8+
### Performance improvements
9+
10+
* (android) Reduce memory consumption for ML Kit ([#82](https://github.com/ionic-team/capacitor-barcode-scanner/pull/82))
911

1012

1113

example-app/android/app/capacitor.build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ android {
99

1010
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
1111
dependencies {
12-
implementation project(':capacitor-app')
1312
implementation project(':capacitor-barcode-scanner')
14-
implementation project(':capacitor-haptics')
15-
implementation project(':capacitor-keyboard')
16-
implementation project(':capacitor-status-bar')
1713

1814
}
1915

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
22
include ':capacitor-android'
3-
project(':capacitor-android').projectDir = new File('../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/android/capacitor')
4-
5-
include ':capacitor-app'
6-
project(':capacitor-app').projectDir = new File('../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app/android')
3+
project(':capacitor-android').projectDir = new File('../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/android/capacitor')
74

85
include ':capacitor-barcode-scanner'
96
project(':capacitor-barcode-scanner').projectDir = new File('../../plugin/android')
10-
11-
include ':capacitor-haptics'
12-
project(':capacitor-haptics').projectDir = new File('../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/haptics/android')
13-
14-
include ':capacitor-keyboard'
15-
project(':capacitor-keyboard').projectDir = new File('../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/keyboard/android')
16-
17-
include ':capacitor-status-bar'
18-
project(':capacitor-status-bar').projectDir = new File('../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/status-bar/android')

example-app/ios/App/Podfile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative '../../../node_modules/.pnpm/@capacitor+ios@7.0.0-rc.0_@capacitor+core@7.0.0-rc.0/node_modules/@capacitor/ios/scripts/pods_helpers'
1+
require_relative '../../../node_modules/.pnpm/@capacitor+ios@7.4.3_@capacitor+core@7.4.3/node_modules/@capacitor/ios/scripts/pods_helpers'
22

33
platform :ios, '14.0'
44
use_frameworks!
@@ -9,13 +9,9 @@ use_frameworks!
99
install! 'cocoapods', :disable_input_output_paths => true
1010

1111
def capacitor_pods
12-
pod 'Capacitor', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios'
13-
pod 'CapacitorCordova', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios'
14-
pod 'CapacitorApp', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app'
12+
pod 'Capacitor', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios'
13+
pod 'CapacitorCordova', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios'
1514
pod 'CapacitorBarcodeScanner', :path => '../../../plugin'
16-
pod 'CapacitorHaptics', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/haptics'
17-
pod 'CapacitorKeyboard', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/keyboard'
18-
pod 'CapacitorStatusBar', :path => '../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/status-bar'
1915
end
2016

2117
target 'App' do

example-app/ios/App/Podfile.lock

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,35 @@
11
PODS:
2-
- Capacitor (7.0.0-rc.0):
2+
- Capacitor (7.4.3):
33
- CapacitorCordova
4-
- CapacitorApp (7.0.0-rc.0):
4+
- CapacitorBarcodeScanner (2.0.4):
55
- Capacitor
6-
- CapacitorBarcodeScanner (2.0.1):
7-
- Capacitor
8-
- OSBarcodeLib (~> 1.1.3)
9-
- CapacitorCordova (7.0.0-rc.0)
10-
- CapacitorHaptics (7.0.0-rc.0):
11-
- Capacitor
12-
- CapacitorKeyboard (7.0.0-rc.0):
13-
- Capacitor
14-
- CapacitorStatusBar (7.0.0-rc.0):
15-
- Capacitor
16-
- OSBarcodeLib (1.1.3)
6+
- OSBarcodeLib (= 2.0.1)
7+
- CapacitorCordova (7.4.3)
8+
- OSBarcodeLib (2.0.1)
179

1810
DEPENDENCIES:
19-
- "Capacitor (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios`)"
20-
- "CapacitorApp (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app`)"
11+
- "Capacitor (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios`)"
2112
- CapacitorBarcodeScanner (from `../../../plugin`)
22-
- "CapacitorCordova (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios`)"
23-
- "CapacitorHaptics (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/haptics`)"
24-
- "CapacitorKeyboard (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/keyboard`)"
25-
- "CapacitorStatusBar (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/status-bar`)"
13+
- "CapacitorCordova (from `../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios`)"
2614

2715
SPEC REPOS:
2816
trunk:
2917
- OSBarcodeLib
3018

3119
EXTERNAL SOURCES:
3220
Capacitor:
33-
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios"
34-
CapacitorApp:
35-
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app"
21+
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios"
3622
CapacitorBarcodeScanner:
3723
:path: "../../../plugin"
3824
CapacitorCordova:
39-
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios"
40-
CapacitorHaptics:
41-
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/haptics"
42-
CapacitorKeyboard:
43-
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/keyboard"
44-
CapacitorStatusBar:
45-
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/status-bar"
25+
:path: "../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios"
4626

4727
SPEC CHECKSUMS:
48-
Capacitor: e79eb426d47f13ee0e2fdaff9ef0e9990db34a48
49-
CapacitorApp: a50750608d62c0ff1fe7f33d38365dd915bb0f31
50-
CapacitorBarcodeScanner: 67bdccc07abc05c3993e83da0196fedef7f5d508
51-
CapacitorCordova: 8f4f6826f0b40f7b506eb13b832039b7140a88b4
52-
CapacitorHaptics: 51c7ca77b24d5448bd716db4f6d5b47302ab9566
53-
CapacitorKeyboard: 342c56b26934429f58ec25fdbe9d4b6553969f8d
54-
CapacitorStatusBar: 89f0dc71f6544cef1dd250dfdb347a25547532b4
55-
OSBarcodeLib: f2e981270a64faf476cb790864262b29ab8cd68a
28+
Capacitor: b4741ca7affb32c1b70debd03df92cbf522d8a80
29+
CapacitorBarcodeScanner: b8a3d4ed0a0d2ed2cd78a16b76737cacbf8da207
30+
CapacitorCordova: 435121e81a2df4d0034f0fb11fcefab5104cfdb5
31+
OSBarcodeLib: 57987d2eb1f916f701f4554e20e349b3cb83f023
5632

57-
PODFILE CHECKSUM: 7bd915a9b237ee006f510f6135ab6eb2a3e55593
33+
PODFILE CHECKSUM: fdf735c62a9097dffa919e728a30c55c44e3a7f6
5834

5935
COCOAPODS: 1.16.2

0 commit comments

Comments
 (0)