BarcodeScanner Data Types

BarcodeScanner defines several data types.

An object representing a scanned barcode.

Property NameTypeDescriptionExample
typeBarcodeTypeThe type of barcode that was recognized. Available values are enumerated in BarcodeScanner.barcodeTypes.
  • "ean13" (the string value of myScanner.barcodeTypes.EAN_13)
  • "qr" (the string value of myScanner.barcodeTypes.QR)
valueStringThe decoded value of the barcode.

An object representing configuration details for a barcode scanning session.

Property NameTypeDescriptionExample
barcodeTypesBarcodeType[]Optional. Specifies the types of barcodes to scan for. Available values are enumerated in BarcodeScanner.barcodeTypes. Defaults to all supported barcode types.[myScanner.barcodeTypes.EAN_13, myScanner.barcodeTypes.QR, myScanner.barcodeTypes.DATA_MATRIX]
instructionTextStringOptional. Provides instructions to display in the scanning interface. Defaults to no text."Scan the next item on the shelf"
successTextStringOptional. Provides a message to display in the scanning interface when a barcode is successfully scanned. Defaults to no text."Item scanned"
showSuccessCheckMarkBooleanOptional. Indicates whether a check mark is displayed upon a successful scan. Defaults to true.false
supportInvertedColorsBooleanOptional. Indicates whether the barcode scanner attempts to scan barcodes that are printed in inverted colors (for example, white-on-black instead of the standard black-on-white). Android only (ignored on iOS). Defaults to false. Note: By default, Android devices don't support scanning inverted color barcodes. The supportInvertedColors option enables most (not all) Android devices to scan inverted color barcodes. Results may vary when scanning inverted color barcodes.false
vibrateOnSuccessBooleanOptional. Determines whether the device vibrates when a scan is successful. Defaults to true.false
scannerSizeStringOptional. Modifies the size of the scanner camera view. The available options represent a percentage of the user's device screen size.
  • SMALL: 25%
  • MEDIUM: 33%
  • LARGE: 50%
  • XLARGE: 75%
  • FULLSCREEN: 100%
Defaults to XLARGE.
"MEDIUM"
cameraFacingStringOptional. Specifies whether the front- or rear-facing camera is used. Defaults to "BACK". Available options include "FRONT" and "BACK". If the user's device doesn't support the specified camera facing, an error is returned."FRONT"
backgroundViewHTMLStringOptional. Defines a custom user interface for the scanner instead of using the standard UI. Defaults to null. If nothing is passed in for this parameter, the standard UI is used. If a custom UI is used, it completely replaces the standard UI, including the standard Cancel button used for dismissing the scanner. When defining a custom UI, it's the responsibility of the caller to handle dismissing the scanner.
presentWithAnimationBooleanOptional. Determines whether the scanner animates in and out when presented and dismissed. Defaults to true.false
manualConfirmationBooleanOptional. Determines whether the user has to manually confirm that a detected barcode should be scanned. Defaults to false.true
previewBarcodeDataBooleanOptional. Determines whether the scanner displays the barcode data while scanning. Defaults to true. Previewing barcode is only supported when backgroundViewHTML is omitted.false
enableBulkScanBooleanOptional. Determines whether the scanner collects the results of scanned barcodes before sending them back to the caller. Defaults to false. When set to true, the scanner collects the results of scanned barcodes and displays them on the screen. When the user taps done, the scanned barcode data is sent back to the caller.true
enableMultiScanBooleanOptional. Determines whether the scanner detects multiple barcodes simultaneously. Defaults to false. Setting this parameter to true automatically sets the enableBulkScan parameter to true.true
enableFlashlightBooleanOptional. Determines whether the device flashlight should be turned on when scanning barcodes. This takes effect only if cameraFacing is set to back-facing camera.true
enableScanLineBooleanOptional. When enabled, the scanner UI displays a scan line. Only barcodes touched by this line are detected; others within view are ignored. Defaults to false.true
initialZoomFactorNumberOptional. Determines the initial zoom factor setting for the device's camera. Defaults to 1.0 (1x or no magnification). For frequent scanning of small barcodes, increasing this value to 2.0 or 4.0 launches the scanner with 2x or 4x magnification, respectively, simplifying the process without requiring manual zooming. However, users retain the ability to further adjust the zoom using pinch-to-zoom. Note that if you provide a zoom factor that is outside the min or max range which the device camera supports, then your value is clamped to the min or max zoom factor that's supported by the device camera.2.0

An object representing an error that occurred when attempting to scan a barcode.

Property NameTypeDescription
codeBarcodeScannerFailureCodeA value representing the reason for the scanning failure. Possible codes include the following:
  • USER_DISMISSED_SCANNER
  • USER_DENIED_PERMISSION
  • USER_DISABLED_PERMISSION
  • INVALID_BARCODE_TYPE_REQUESTED
  • SERVICE_NOT_ENABLED
  • UNKNOWN_REASON
messageStringA string value explaining the reason for the scanning failure. This value is suitable for use in user interface messages. The message is provided in English, and isn’t localized.

userDismissedScanner is returned when the user clicks the Cancel button during scanning. This is the normal method of terminating a scanning session. Your error handling can check for and possibly treat userDismissedScanner differently from, for example, permissions errors.