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,
  cameraType
}
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. String
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.

Object
cameraType

Optional parameter that specifies the camera that is used to scan the barcode:

  • The value of "CAMERA_TYPE_BACK" means that the scanner will use the device's main camera. This is the default mode.

  • The value of "CAMERA_TYPE_FRONT" means that the scanner will use the device's front camera.

This parameter is not supported on Android.

String

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 © 2019 and Confidential to Pegasystems Inc. All rights reserved
Pega Community | Feedback
Advanced...