1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154# @capacitor/barcode-scanner
Capacitor plugin using Outsystems Barcode libs
## Install
```bash
npm install @capacitor/barcode-scanner
npx cap sync
```
#### Android
The barcode scanner plugin requires a minimum Android SDK target of 26. This is higher than the default that comes with your Capacitor application. You can update this value in your `android/variables.gradle` file.
```gradle
ext {
minSdkVersion = 26
}
```
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.
#### iOS
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.
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.
---
## API
<docgen-index>
* [`scanBarcode(...)`](#scanbarcode)
* [Type Aliases](#type-aliases)
* [Enums](#enums)
</docgen-index>
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
Interface defining the contract for a plugin capable of scanning barcodes.
Requires implementation of the scanBarcode method, which initiates a barcode scan with given options.
Starting in Android targetSdk 36, the scanOrientation parameter has no effect for large screens (e.g. tablets) on Android 16 and higher.
You may opt-out of this behavior in your app by adding `<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />` to your `AndroidManifest.xml` inside `<application>` or `<activity>`.
Keep in mind though that this opt-out is temporary and will no longer work for Android 17. Android discourages setting specific orientations for large screens.
Regular Android phones are unaffected by this change.
For more information check the Android docs at https://developer.android.com/about/versions/16/behavior-changes-16#adaptive-layouts
### scanBarcode(...)
```typescript
scanBarcode(options: CapacitorBarcodeScannerOptions) => Promise<CapacitorBarcodeScannerScanResult>
```
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#capacitorbarcodescanneroptions">CapacitorBarcodeScannerOptions</a></code> |
**Returns:** <code>Promise<<a href="#capacitorbarcodescannerscanresult">CapacitorBarcodeScannerScanResult</a>></code>
--------------------
### Type Aliases
#### CapacitorBarcodeScannerScanResult
Defines the structure of the result returned from a barcode scan.
<code>{ ScanResult: string; format: <a href="#capacitorbarcodescannertypehint">CapacitorBarcodeScannerTypeHint</a>; }</code>
#### CapacitorBarcodeScannerTypeHint
Extends supported formats from Html5Qrcode with a special 'ALL' option,
indicating support for all barcode types.
Type definition combining <a href="#html5qrcodesupportedformats">Html5QrcodeSupportedFormats</a> and OSBarcodeTypeHintALLOption
to represent the hint for the type of barcode to be scanned.
<code><a href="#html5qrcodesupportedformats">Html5QrcodeSupportedFormats</a> | <a href="#capacitorbarcodescannertypehintalloption">CapacitorBarcodeScannerTypeHintALLOption</a></code>
#### CapacitorBarcodeScannerOptions
Defines the options for configuring a barcode scan.
<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>
### Enums
#### Html5QrcodeSupportedFormats
| Members | Value |
| ----------------------- | --------------- |
| **`QR_CODE`** | <code>0</code> |
| **`AZTEC`** | <code>1</code> |
| **`CODABAR`** | <code>2</code> |
| **`CODE_39`** | <code>3</code> |
| **`CODE_93`** | <code>4</code> |
| **`CODE_128`** | <code>5</code> |
| **`DATA_MATRIX`** | <code>6</code> |
| **`MAXICODE`** | <code>7</code> |
| **`ITF`** | <code>8</code> |
| **`EAN_13`** | <code>9</code> |
| **`EAN_8`** | <code>10</code> |
| **`PDF_417`** | <code>11</code> |
| **`RSS_14`** | <code>12</code> |
| **`RSS_EXPANDED`** | <code>13</code> |
| **`UPC_A`** | <code>14</code> |
| **`UPC_E`** | <code>15</code> |
| **`UPC_EAN_EXTENSION`** | <code>16</code> |
#### CapacitorBarcodeScannerTypeHintALLOption
| Members | Value |
| --------- | --------------- |
| **`ALL`** | <code>17</code> |
#### CapacitorBarcodeScannerCameraDirection
| Members | Value |
| ----------- | -------------- |
| **`BACK`** | <code>1</code> |
| **`FRONT`** | <code>2</code> |
#### CapacitorBarcodeScannerScanOrientation
| Members | Value |
| --------------- | -------------- |
| **`PORTRAIT`** | <code>1</code> |
| **`LANDSCAPE`** | <code>2</code> |
| **`ADAPTIVE`** | <code>3</code> |
#### CapacitorBarcodeScannerAndroidScanningLibrary
| Members | Value |
| ----------- | -------------------- |
| **`ZXING`** | <code>"zxing"</code> |
| **`MLKIT`** | <code>"mlkit"</code> |
</docgen-api>