|
1 | 1 | # cordova-outsystems-barcode |
2 | 2 |
|
3 | | -## Cordova Bridge for the OutSystems Officially Supported Barcode Plugin. |
| 3 | +*This plugin is SUPPORTED by OutSystems. Customers entitled to Support Services may obtain assistance through Support.* |
| 4 | + |
| 5 | +A barcode scanner for your mobile application. Supports many popular encoding types of 1D and 2D barcodes, presented in the following table. |
| 6 | + |
| 7 | +**1D Barcodes** |
| 8 | + |
| 9 | +|Code|iOS|Android's ML Kit|Android's ZXing| |
| 10 | +|:-|:-:|:-:|:-:| |
| 11 | +|Codabar|:warning:<br>(Available from 15.0)|:white_check_mark:|:white_check_mark:| |
| 12 | +|Code 39|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 13 | +|Code 93|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 14 | +|Code 128|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 15 | +|Databar (GS1)|:warning:<br>(Available from 15.0)|:x:|:white_check_mark:| |
| 16 | +|EAN-8|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 17 | +|EAN-13|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 18 | +|ITF|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 19 | +|ITF-14|:white_check_mark:|:x:|:x:| |
| 20 | +|ISBN-10|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 21 | +|ISBN-13|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 22 | +|ISBN-13 Dual Barcode|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 23 | +|RSSExpanded|:warning:<br>(Available from 15.0)|:x:|:white_check_mark:| |
| 24 | +|UPC-A|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 25 | +|UPC-E|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 26 | + |
| 27 | +**2D Barcodes** |
| 28 | + |
| 29 | +|Code|iOS|Android's ML Kit|Android's ZXing| |
| 30 | +|:-|:-:|:-:|:-:| |
| 31 | +|Aztec Code|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 32 | +|Data Matrix|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 33 | +|MaxiCode|:x:|:x:|:white_check_mark:| |
| 34 | +|Micro PDF 417|:warning:<br>(Available from 15.0)|:x:|:x:| |
| 35 | +|Micro QR|:warning:<br>(Available from 15.0)|:x:|:x:| |
| 36 | +|PDF 417|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 37 | +|QR Code|:white_check_mark:|:white_check_mark:|:white_check_mark:| |
| 38 | + |
| 39 | +## Installation |
| 40 | + |
| 41 | +```console |
| 42 | +cordova plugin add <path-to-repo-local-clone> |
| 43 | +``` |
| 44 | + |
| 45 | +It's also possible to install via the repo's URL directly. |
| 46 | + |
| 47 | +```console |
| 48 | +cordova plugin add https://github.com/OutSystems/cordova-outsystems-barcode |
| 49 | +``` |
| 50 | + |
| 51 | +## Supported Platforms |
| 52 | + |
| 53 | +- iOS |
| 54 | +- Android |
| 55 | + |
| 56 | +## Methods |
| 57 | + |
| 58 | +* OSBarcode |
| 59 | + * [scanBarcode](#scan-barcode) |
| 60 | + |
| 61 | +* OSBarcodeScanner |
| 62 | + * [scan](#scan) |
| 63 | + |
| 64 | +### Scan Barcode |
| 65 | + |
| 66 | +```js |
| 67 | +cordova.plugins.OSBarcode.scanBarcode(options, successCallback, errorCallback); |
| 68 | +``` |
| 69 | + |
| 70 | +An action that triggers the barcode reader. If successful, it returns the text associated with the scanned barcode as a String. In case of an error, it returns the associated error code and message (TODO: link to the table). |
| 71 | + |
| 72 | +The action is composed of the following parameters: |
| 73 | + |
| 74 | +- **options**: A structure containing some configurations to apply to the barcode reader. It's composed of the following properties: |
| 75 | + - **scanInstructions**: A text containing the scanning instructions. |
| 76 | + - **cameraDirection**: An integer that indicates if the back (1) or front (2) camera will be used when triggering a new scan action. |
| 77 | + - **scanOrientation**: An integer that indicates which orientation will the scanner assume: Portrait (1), Landscape (2) or Adaptive (3). "Adaptive" uses the device's current orientation. |
| 78 | + - **scanButton**: A boolean that will display a scan button on the barcode reader. With the button, scanning will only be triggered when pressing the button instead of automatically when framing the barcode. A second click on the button disables scannning. |
| 79 | + - **scanText**: A text to be displayed on the scan button. It will only be shown if **scanButton** is set to true. |
| 80 | + - **androidScanningLibrary**: A text equivalent to the **OSBarcodeConstants.AndroidScanningLibrary** structure. It indicates which library will be used to perform the scan: MLKit or ZXing. As the name indicates, it's only applicable to "Android". |
| 81 | +- **successCallback**: A structure indicating that the action was successful. It returns a **ScanResult**: a text containing the value associated with the scanned barcode. |
| 82 | +- **errorCallback**: A structure indicating that the action was not successful. It returns an "error" structure, composed of: |
| 83 | + - **code**: A text containing the error code. |
| 84 | + - **message**: A text containing the error message. |
| 85 | + |
| 86 | +### Scan |
| 87 | + |
| 88 | +```js |
| 89 | +cordova.plugins.OSBarcodeScanner.scan(options, successCallback, errorCallback); |
| 90 | +``` |
| 91 | + |
| 92 | +Being the older way to trigger the barcode reader, this was kept to keep retro compatibility. This action calls the [Scan Barcode](#scan-barcode) action, with the possible outputs being the same. |
| 93 | + |
| 94 | +The action is composed of the following parameters: |
| 95 | + |
| 96 | +- **options**: A structure containing some configurations to apply to the barcode reader. It's composed of the following properties: |
| 97 | + - **scanInstructions**: A text containing the scanning instructions. |
| 98 | + - **cameraDirection**: An integer that indicates if the back (1) or front (2) camera will be used when triggering a new scan action. |
| 99 | + - **scanOrientation**: An integer that indicates which orientation will the scanner assume: Portrait (1), Landscape (2) or Adaptive (3). "Adaptive" uses the device's current orientation. |
| 100 | + - **scanButton**: A boolean that will display a scan button on the barcode reader. With the button, scanning will only be triggered when pressing the button instead of automatically when framing the barcode. A second click on the button disables scannning. |
| 101 | + - **scanText**: A text to be displayed on the scan button. It will only be shown if **scanButton** is set to true. |
| 102 | +- **successCallback**: A structure indicating that the action was successful. It returns a **ScanResult**: a text containing the value associated with the scanned barcode. |
| 103 | +- **errorCallback**: A structure indicating that the action was not successful. It returns an "error" structure, composed of: |
| 104 | + - **code**: A text containing the error code. |
| 105 | + - **message**: A text containing the error message. |
| 106 | + |
| 107 | +## Errors |
| 108 | + |
| 109 | +|Code|Message|iOS|Android| |
| 110 | +|:-|:-|:-:|:-:| |
| 111 | +|OS-PLUG-BARC-0004|Error while trying to scan code.|:white_check_mark:|:white_check_mark:| |
| 112 | +|OS-PLUG-BARC-0006|Couldn't scan because the process was cancelled.|:white_check_mark:|:white_check_mark:| |
| 113 | +|OS-PLUG-BARC-0007|Couldn't scan because camera access wasn’t provided. Check your camera permissions and try again.|:white_check_mark:|:white_check_mark:| |
| 114 | +|OS-PLUG-BARC-0008|Scanning parameters are invalid.|:white_check_mark:|:white_check_mark:| |
| 115 | +|OS-PLUG-BARC-0009|There was an error scanning the barcode with ZXing.|:x:|:white_check_mark:| |
| 116 | +|OS-PLUG-BARC-0010|There was an error scanning the barcode with ML Kit.|:x:|:white_check_mark:| |
0 commit comments