Scan Barcode

Use the Scan Barcode action in your mobile application to scan QR codes and barcodes for details such as URLs, Wi-Fi connections, and contact information.

The parameters for this action are:

Parameter Name Description
image An image object, which can be a CanvasImageSource, Blob, ImageData, or an <img> element
formats Optional: A series of barcode formats to search for, for example, one or more of the following:

['aztec', 'code_128', 'code_39', 'code_93', 'codabar', 'data_matrix', 'ean_13', 'ean_8', itf', 'pdf417', 'qr_code', 'upc_a', 'upc_e']

Note that all formats may not be supported on all platforms.

If formats is not specified, the browser will search all supported formats, so limiting the search to a particular subset of supported formats may provide better performance.

convertBlob Optional: A boolean that enables you to automatically convert a Blob to an ImageBitmap when using the Scan Barcode action to process the outcome of the Take Photo action. If true, the Blob object is converted as an ImageBitmap before being passed to the Scan Barcode action. If false (default), the Blob object is left as is. You'll need to manually do the conversion, for example, by adding a function to your application and calling the function using the callModuleFunctionAction in your action chain.
Here's an example of a call to the Scan Barcode action, in which a bitmap returned by a module function is used for the Image parameter:
      const scanCreateImageBitmapResultResult = await Actions.barcode(context, {
        image: createImageBitmapResult,
        formats: [
          'qr_code',
        ],
      });

Return Values

On success, a DetectedBarcode object is returned using the auto-generated variable shown by the Store Results In parameter. If the browser does not support the Shape Detection API or if a specified format is not supported, an exception is thrown.