Capacitor plugin using Outsystems Barcode libs
npm install bpw-barcode-scannerbash
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
}
`
You will need to modify the allprojects > repositories section in your android/build.gradle file to include the Outsystems repository. Your android/build.gradle file should look similar to this after adding the repository.
`gradle
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://pkgs.dev.azure.com/OutSystemsRD/9e79bc5b-69b2-4476-9ca5-d67594972a52/_packaging/PublicArtifactRepository/maven/v1'
name 'Azure'
credentials {
username = "optional"
password = ""
}
content {
includeGroup "com.github.outsystems"
}
}
}
}
`
#### 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.
---
API
scanBarcode(...)
* Type Aliases
* Enums
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.
$3
`typescript
scanBarcode(options: CapacitorBarcodeScannerOptions) => Promise
`| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
|
options | CapacitorBarcodeScannerOptions |Returns: Promise<CapacitorBarcodeScannerScanResult>
--------------------
$3
#### CapacitorBarcodeScannerScanResult
Defines the structure of the result returned from a barcode scan.
{ ScanResult: string }
#### CapacitorBarcodeScannerOptions
Defines the options for configuring a barcode scan.
{
hint: CapacitorBarcodeScannerTypeHint;
scanInstructions?: string;
scanButton?: boolean;
scanText?: string;
cameraDirection?: CapacitorBarcodeScannerCameraDirection;
scanOrientation?: CapacitorBarcodeScannerScanOrientation;
android?: {
scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary;
};
web?: {
showCameraSelection?: boolean;
scannerFPS?: number;
};
}
#### CapacitorBarcodeScannerTypeHint
Extends supported formats from Html5Qrcode with a special 'ALL' option,
indicating support for all barcode types.
Type definition combining Html5QrcodeSupportedFormats and OSBarcodeTypeHintALLOption
to represent the hint for the type of barcode to be scanned.
Html5QrcodeSupportedFormats | CapacitorBarcodeScannerTypeHintALLOption
$3
#### Html5QrcodeSupportedFormats
| Members | Value |
| ----------------------- | --------------- |
|
QR_CODE | 0 |
| AZTEC | 1 |
| CODABAR | 2 |
| CODE_39 | 3 |
| CODE_93 | 4 |
| CODE_128 | 5 |
| DATA_MATRIX | 6 |
| MAXICODE | 7 |
| ITF | 8 |
| EAN_13 | 9 |
| EAN_8 | 10 |
| PDF_417 | 11 |
| RSS_14 | 12 |
| RSS_EXPANDED | 13 |
| UPC_A | 14 |
| UPC_E | 15 |
| UPC_EAN_EXTENSION | 16 |
#### CapacitorBarcodeScannerTypeHintALLOption
| Members | Value |
| --------- | --------------- |
|
ALL | 17 |
#### CapacitorBarcodeScannerCameraDirection
| Members | Value |
| ----------- | -------------- |
|
BACK | 1 |
| FRONT | 2 |
#### CapacitorBarcodeScannerScanOrientation
| Members | Value |
| --------------- | -------------- |
|
PORTRAIT | 1 |
| LANDSCAPE | 2 |
| ADAPTIVE | 3 |
#### CapacitorBarcodeScannerAndroidScanningLibrary
| Members | Value |
| ----------- | -------------------- |
|
ZXING | 'zxing' |
| MLKIT` | 'mlkit' |