Skip to content

Barcode Scanning Service

o5faruk edited this page May 2, 2021 · 5 revisions

⚠️⚠️⚠️

This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/barcode-scanning/

⚠️⚠️⚠️

This service accesses the device camera and scans for barcodes in their various forms.

Using the service

Prerequisites

This only works on the Widget side of a plugin. On the widget page you need to include scripts/buildfire/services/camera/barcodeScanner.js:

<script src="../../../scripts/buildfire/services/camera/barcodeScanner.js"></script>

Your plugin also needs to include the Feature BarCodeScanner

Implementation

A new namespace becomes avaiable buildfire.services.camera.barcodeScanner. This represents a singleton object barcodeScanner

Methods:

barcodeScanner.scan(options, callback) this will invoke the scanning process. It may also ask the user for permission to access the Camera if it hasn't previously.

  • options: this is an object containing the various options available
    • preferFrontCamera : bool. Preference to start with the Front Camera or Back if available on the device.
    • showFlipCameraButton : bool. Allow user to flip between camera's
    • showTorchButton : bool. On some devices you can turn on the back light
    • torchOn : bool. Android only. launch with the torch switched on (if available).
    • prompt : string. Android only. Defaults to "Place a barcode inside the scan area".
    • resultDisplayDuration : int. Milliseconds. Android only. Display scanned text for X ms. 0 suppresses it entirely, default 1500
    • formats : string. Comma separated values. Example "QR_CODE,PDF_417". Default all but PDF_417 and RSS_EXPANDED
buildfire.services.camera.barcodeScanner.scan(
       {
            preferFrontCamera : true, 
            showFlipCameraButton : true,
            formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
        },
        function (err, result) {
            buildfire.notifications.alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
        }
    );

Supported Barcode Formats

The following barcode types are currently supported:

Android

  • QR_CODE
  • DATA_MATRIX
  • UPC_E
  • UPC_A
  • EAN_8
  • EAN_13
  • CODE_128
  • CODE_39
  • CODE_93
  • CODABAR
  • ITF
  • RSS14
  • RSS_EXPANDED

Not by default, but supported if you pass in the "formats" option:

  • PDF417
  • AZTEC

iOS

  • QR_CODE
  • DATA_MATRIX
  • UPC_E
  • UPC_A
  • EAN_8
  • EAN_13
  • CODE_128
  • CODE_39
  • ITF

Clone this wiki locally