The Barcode Plugin works with native mobile apps and lets users of the app scan 1D and 2D barcodes. Set the options in the plugin to customize the scanner, to add instructions, or change camera direction.
See Adding plugins to learn how to install and reference a plugin in your OutSystems apps, and how to install a demo app.
OutSystems provides a demo app to help you learn how to use this plugin. Install the Barcode Demo App from Forge and then open the app in Service Studio. The demo app contains logic for common use cases, that you can examine and create in your apps. For example, how to:
- Scan a code
- Use the a predefined UI block
- Create a settings page
Here is the settings screen:
Creating a user interface
To set up the user interface, see an example for the Camera plugin. You can use a similar approach in your app with the Barcode plugin.
Creating logic to scan a code
To create the logic to scan for barcodes, follow these steps in Service Studio:
Go to Logic > Client Actions > BarcodePlugin.
To open the camera in your app for scanning, drag the ScanBarcode action to the flow.
In the ScanBarcode action you can set scan instructions, back or front camera, or UI orientation, and enable the scan button. For more information about the ScanBarcode action, see Scanning options.
Check the ScanResult text for the result of the scan.
To prevent errors, it's a good practice to first check if the plugin is available using the action CheckBarcodePlugin. To confirm the device can read the barcodes, verify that the value of ScanBarcode.Success is true. See the demo app for the examples.
More information about the plugin.
Supported barcode formats
The following list shows which barcode formats the plugin can read.
- ISBN-13 Dual Barcode
- Code 39
- Code 93
- Code 128
- GS1 DataBar
- QR Code
- PDF 417
- Data Matrix
- Aztec Code
Here is the list of the actions you can use in the plugin actions.
|ScanInstructions||Displays the scanning instructions.|
|CameraDirection||Select the front or back camera as default when triggering a new scan action.|
|ScanOrientation||Allows you to set the Scan UI to Adaptive, which detects your device's orientation, Landscape, or Portrait mode.|
|ScanLine||If set to true, enables a white line-of-sight that sweeps the screen when scanning the code.|
|ScanButton||If set to true, enables a scan button in the Scan UI. Pressing the button triggers the scan action, instead of scanning automatically when framing the code.|
The Barcode Plugin uses a Cordova plugin, and for more information check cordova-outsystems-barcodescanner.
What follows is the list of known issues and workarounds.
Reading a PDF147 can crash an app
Applies to iOS only.
Reading a PDF147 barcode can crash an iOS app. OutSystems is working on a potential fix.
Poor scanning results with the front camera
On some devices with a low-resolution front camera, the app doesn't scan barcodes well. For best results use the back camera. The back camera has higher resolution and can focus better on a barcode.