App.Scanner

App.Scanner

Scanner module responsible for scanning QR/ EAN/ DataMatrix codes

Note: Following code formats are supported.

EAN-8, EAN-13, Code 39, Code 128, ITF, RSS-14, QR Code, Data Matrix

Classes

Scanner

Methods

(static) create(options) → {App.Scanner.Scanner}

Creates new scanner instance

Example
// 1. Auto Scan
// .. default scan action, open object or search for scanned text
App.scanner.create();

// .. get control when item is scanned
App.scanner.create({options: {
   'onScanComplete': scannedText => {console.log(scannedText)},
 }});

// 2. Manual Scan
const scanner = App.scanner.create({options: {
   'onScanComplete': scannedText => {console.log(scannedText)},
   'autoScan': false
 }});

 // .. using default camera
 scanner.startScanning();
 ...
 scanner.stopScanning();

// .. using preferred camera
 scanner.initScanners()
     .then(scanner.renderUi)
     .then(() => {
         const scanners = scanner.getScanners();
         const deviceId = '<logic to get preferred camera from scanners>';
         return deviceId;
     })
     .then(scanner.scan)
     .catch(scanner.handleError);
Parameters:
Name Type Description
options object

options passed to the scanner instance

Properties
Name Type Attributes Default Description
onScanComplete function <optional>

callback invoked when result is found. If not provided, will either launch search for resolved code or open object page

autoScan boolean <optional>
true

should it automatically start scanning? Pass false if you want to programmatically control scanner, e.g. with different camera instance etc.

Returns:
Type
App.Scanner.Scanner