HardwareBarcode
JourneyApps supports the use of certain devices with hardware barcode scanning capabilities.
Device Compatibility
Hardware barcode scanning is currently only supported on Unitech PA700 devices. Please contact JourneyApps Support if you are considering other devices for hardware barcode scanning.
This feature is currently only available for customers on the Enterprise plan.
Hardware barcode scanning is managed entirely through JavaScript/TypeScript and does not require any specific view components or data types.
Device Capabilities
The HardwareBarcode.getCapabilities
method returns details about the hardware barcode scanning capabilities of the current device. The return object contains the following properties:
description
string
Description of hardware barcode scanner.
supported
boolean
If hardware barcode scanning is supported on the current device.
softwareTriggerSupported
boolean
If software triggering of hardware barcode scanner is supported on the current device.
Example JavaScript:
Hardware Barcode Scanner Registration
If hardware barcode scanning is supported on the current device, then the scanning service can be started and a callback function registered.
The HardwareBarcode.register
method must be called with the callback function to register as the scanning handler. Only a single callback function can be registered. This must be performed before scanning is attempted.
In the example JavaScript below, the scanning service is started and the onScan
function registered as a callback:
The onScan
function from the example will be called each time that a barcode is scanned with the barcode data as parameter. The barcode object contains the following methods:
toBase64
string
Returns the barcode data as a base64-encoded string.
toArrayBuffer
ArrayBuffer
Returns the raw binary data of the barcode.
The hardware barcode scanning service should be stopped when no longer needed as shown in the example JavaScript:
This will remove the registered scanning handler function.
The callback is automatically deregistered when navigating away from the view.
Software Triggering
If the device supports software triggering then the hardware barcode scanner can be triggered manually as shown in the example JavaScript:
Software triggering can be used in place of a dedicated hardware scan button on the device. The scanning handler function is invoked in the same way regardless of triggering method.
Complete Example
The example below demonstrates the usage of the hardware barcode scanning functionality. The device capabilities are checked and if hardware barcode scanning is supported, then the scanner is registered when the view is loaded. The barcode data will be displayed as a Base64-encoded string when the hardware scan button is pressed.
View JavaScript:
Last updated