scan


Purpose

Launches the barcode scanning process and displays the full-screen live camera preview.

Signature

scan( options, callbacks )

Returns

This method does not return anything.

Parameters

The table below describes the parameters included in the options object, which may be structured as follows:

{ 
  scanMode,
  characterSet,
  cropArea
}
Parameter Description Type
scanMode Defines the scan mode. The value of "SCAN_MODE_ALL" means that the scanner will attempt to detect all supported barcode types. This is the default mode. The value of "SCAN_MODE_PRODUCT" means that the scanner will attempt to detect product type barcodes. "SCAN_MODE_1D" means that the scanner will attempt to detect all one dimensional barcode types (1D). The value of "SCAN_MODE_QR_CODE" means that the scanner will attempt to detect QR barcodes. "SCAN_MODE_DATA_MATRIX" means that the scanner will attempt to detect data matrix type barcodes. Int
characterSet

Optional parameter that specifies the character encoding to use when decoding barcode data. The parameter supports the following values: "Shift_JIS", "UTF-8", and "ISO-8859-1".

This parameter is not supported on iOS.

String
cropArea

Optional parameter, a JSON structure containing two fields:

  • width specifies the width of the scanning rectangle area in pixels

  • height specifies the height of the scanning rectangle area in pixels

The whole available area is scanned by default.

This parameter is not supported on iOS.

Int

Callback object structure

The scan method's callbacks object can be structured as follows:

{
  onSuccess: function ( {data, format} ) { ... },
  onCancel: function ( ) { ... },
  onFailure: function ( {code, description} ) { ... }
}

The table below lists callback methods included in the callbacks object.

Name Description Return type
onSuccess Invoked when the scan has been successful. A JSON object passed as its parameter specifies the scanned data and its format. undefined
onCancel A callback method invoked when a scan has been canceled by the user. undefined
onFailure A callback method invoked when a scan has failed for any reason. A JSON object passed as parameter contains detailed information about the error. undefined

Related topics

BarcodeScanner
Legal notice | Copyright © 2016 and Confidential to Pegasystems Inc. All rights reserved
PDN | Hybrid Container | Feedback
Advanced...