Namespace: scanning

airlock.scanning

Provides various functions for working with the hardware barcode scanner.
Source:

Methods

(static) beginScan()

Simulates pressing hardware trigger for the barcode reader.
Source:

(static) endScan()

Ends the simulated pressing of the hardware trigger.
Source:
See:

(static) getApiVersion() → {string}

Gets the API version of the device SDK. This value is retrieved from the device SDK itself.
Source:
Returns:
The API version reported by the device SDK.
Type
string

(static) getConfiguration() → {object}

Returns the scanner configuration as an object. Fields can be set, and the configuration can be applied using setConfiguration.
Source:
See:
Returns:
The reader configuration.
Type
object
Example
var config = airlock.scanning.getConfiguration();
// Displays false
alert(config.displayMode);

(static) getDecoders() → {Promise.<Array.<object>>}

Retrieves all decoders via a Promise.
Source:
Returns:
A list of all decoders.
Type
Promise.<Array.<object>>
Example
airlock.scanning.getDecoders()
.then(function (decoders) {
		var text = "";
		for (let i = 0; i < decoders.length; i++) {
			text += decoders[i].name + ", ";
		}
		alert(text);
	}).catch(function (error) {
		alert(`Error: ${error}`);
	});

(static) getDecoderWithName(decoderName) → {object}

Retrieves the decoder with the specified name. Device makers use different names for decoders. If you are uncertain of the name, use getDecoderWithNativeId instead.
Parameters:
Name Type Description
decoderName string The name of the decoder. Cannot be null.
Source:
See:
Returns:
The decoder object that may allow you to modify its state.
Type
object
Example
var decoder = airlock.scanning.getDecoderWithName('codabar');
// Displays 'codabar'
alert(decoder.name);

(static) getDecoderWithNativeId(id) → {object}

Retrieves the decoder with the specified native identifier, corresponding to the ID within the device SDK.
Parameters:
Name Type Description
id int The id of the decoder. Cannot be null.
Source:
See:
Returns:
The decoder object that may allow you to modify its state.
Type
object
Example
var codabarDecoder = airlock.scanning.getDecoderWithNativeId(71);
// Displays 'codabar'
alert(decoder.name);

(static) getFirmwareVersion() → {string}

Gets the reader firmware version as reported by the device SDK.
Source:
Returns:
The reader firmware version as reported by the device SDK.
Type
string

(static) getReaderModel() → {string}

Gets the reader model as reported by the device SDK.
Source:
Returns:
The reader type as reported by the device SDK.
Type
string

(static) isScannerActive() → {boolean}

Gets a value indicating whether the scanner is ready.
Source:
Returns:
true if the scanner is started and usable; false otherwise.
Type
boolean
Example
var active = airlock.scanning.isScannerActive();
// Display true if active; false otherwise.
alert(active);

(static) resetConfiguration() → {Promise.<boolean>}

Resets the scanner configuration. Resets the current devices configuration and removes any settings stored for the barcode reader, including decoder settings and so forth. An app restart may be required by some device brands.
Source:
Returns:
When resolved indicates the reset is complete. If the resolve value is true, the new configuration has been applied. If false, an app restart is required.
Type
Promise.<boolean>
Example
airlock.scanning.resetConfiguration()
.then(function (defaultSettingsApplied) {
		alert("Configuration reset."
			+ (defaultSettingsApplied ? "" : "Restart required."));
}).catch(function (e) {
		alert("Error: " + e);
});

(static) setConfiguration(configuration)

Applies the specified scanner configuration to the device.
Parameters:
Name Type Description
configuration object The barcode reader configuration.
Source:
Throws:
Thrown if the device SDK is not supported.
Type
ScriptCallException
Example
var config = airlock.scanning.getConfiguration();
config.displayMode = true;
airlock.scanning.setConfiguration(config);

(static) setDecoder(decoder)

Sets the values of a decoder.
Parameters:
Name Type Description
decoder object The decoder object. Cannot be null.
Source:
Throws:
If the device SDK is not supported.
Type
Exception
Example
var codabarDecoder = airlock.scanning.getDecoderWithNativeId(71);
codabarDecoder.enabled = true;
codabarDecoder.notisEditingType = 1;
codabarDecoder.lengthMin = 10;
airlock.scanning.setDecoder(codabarDecoder);

(static) setScannerActive(active)

Starts or stops the scanner.
Parameters:
Name Type Description
active boolean If true the scanner is placed in a started state. If false, the scanner is stopped.
Source:

Type Definitions

ScanErrorEventArgs

Properties:
Name Type Description
errorInfo object SDK dependent information regarding the error.
timestamp Date Indicates when the scan failed.
Source:

ScanEventArgs

Properties:
Name Type Description
rawDataInBase64 string The raw barcode data in Base64 format (if available).
text string The processed barcode data.
nativeSymbologyId string | Number The identifier used in the device manufacturer's SDK for a symbology.
symbologyName string The symbology name, such as 'Code11'.
sourceScanner string The reader ID (if available).
insertMode number Replace = 0, Append = 1, Prepend = 2. Determines the behaviour of the barcode wedge and whether it overwrites, appends, or prepends a text field with the scanned text.
moveToNextField boolean If true, after the scan, the browser will attempt to move to the next field on the page.
keyboardWedgeEnabled boolean If true, it indicates that the app may attempt to populate the current field with the barcode text.
timestamp Date Indicates when the scan occured.
Source:

Events

onScan

onScan Event. Is raised when the barcode reader receives scan data. To subscribe to the event use: airlock.device.onScan.addListener(aFunction) To unsubscribe to the event use: airlock.device.onScan.removeListener(aFunction)
Type:
Source:
Example
// Subscribe
airlock.scanning.onScan.addListener(handleScan);

function handleScan(args) {
		// Displays the barcode data.
		alert(args.text);
}
// Unsubscribe
airlock.scanning.onScan.removeListener(handleScan);

onScanError

onScanError Event. Is raised when the barcode reader fails to scan a barcode. To subscribe to the event use: airlock.device.onScanError.addListener(aFunction) To unsubscribe to the event use: airlock.device.onScanError.removeListener(aFunction)
Type:
Source:
Examples
// Subscribe
airlock.scanning.onScanError.addListener(handleScanError);

function handleScanError(args) {
		// Display error info (if exists)
		alert(args.errorInfo);
}
// Unsubscribe
airlock.scanning.onScanError.removeListener(handleScanError);