i
This is not the latest version of this document; to access the latest version, click here.
Unofficial Content

This Smart Devices API enable to programmatically scan barcodes (2D and QR Codes) using the device's camera.

See also Scanner Control to associate an Edit control (attribute or variable) the possibility to enter barcode information to the field directly from the camera.

ScannerAPI

Scenario

Multiples scenarios can use the device camera in advantage in order to enter information more easily, without the user requiring typing; for instance:

  • Retrieve store's product information from its linear barcode and adding to the shopping cart (App example : Tienda Inglesa)
  • Add contact information reading personal cards / tags including QR Codes (App example: GeneXus Event)
  • Read a sequence of several codes (linear o QR codes) until the user decides to to stop reading. This can be useful to emulate a supermarket cashier.

Code example

In the shopping cart scenario, suppose we have a Scan button in the Layout, to read a product barcode, add it automatically to the cart and finally edit the product in the cart to show the product info and to indicate the quantity:

Event 'Scan'
  Composite
    &ScanBarcode = ScannerAPI.ScanBarcode()
    &CartItemId = CartItem_InsertButNotConfirmed(&ScanBarcode,&Messages )
    WorkWithDevicesCartItem.CartItem.Detail(&CartItemId, &ScanBarcode)
  EndComposite
EndEvent

ScannerAPI Methods

ScanBarcode

To scan a linear barcode or QR code

Return value: String

Parameters: None

ScanBarcode(barcodeTypes)

To scan a linear barcode or QR code filtering a specific list of Barcodes.

Return value: String

Parameters:

  • barcodeTypes: BarcodeType collection; a list of valid Barcodes separated by semicolon.

Example:

&EANBarcodeTypes.Add(BarcodeType.EAN_13)
&ScannedValue = GeneXus.SD.Scanner.ScanBarcode(&EANBarcodeTypes)

ScanInLoop(beepOnEachread)

To scan several barcodes at once. User intervention is not required until it decides to stop reading.

Return value: ScannedBarcodes

Parameters: 

  • BeepOnEachRead: Boolean  (indicates if the scanner emit a sound on each code reading)

ScanInLoop(beepOnEachRead, barcodeTypes)

To scan several barcodes at once using a specific list of barcodes. User intervention is not required until it decides to stop reading.

Return value: ScannedBarcodes

Parameters: 

  • BeepOnEachRead: Boolean  (indicates if the scanner emit a sound on each code reading)
  • barcodeTypes: BarcodeType collection; a list of valid Barcodes separated by semicolon

Example:

&EANBarcodeTypes.Add(BarcodeType.EAN_13)
&ScannedBarcodes = GeneXus.SD.Scanner.ScanInLoop(true, &EANBarcodeTypes)

Data Types

ScannedBarcodes

Type: Collection

Element: BarCode: String

Barcodes

Valid barcodes for iOS are: UPC-E, Code39, Code39Mod43, EAN-13, EAN-8, Code93, Code128, Interleaved2of5, ITF-14, PDF417, QR, Aztec, DataMatrix

See also

HowTo: Use ScanBarcode method from Scanner external object in Native Mobile applications

HowTo: Use the ScanInLoop method from Scanner external object in Native Mobile applications

Notes:

  • ScannerAPI is available as form GeneXus X Evolution 2 Upgrade 3.
  • ScanInLoop method is available as from GeneXus X Evolution 2 Upgrade 3.
  • For GeneXus X Evolution 2 Upgrade 2 or older see HowTo: Using ScanBarcode Method from Interop in SDApi for Smart Devices
  • Methods using the BarcodeType filter is available since GeneXus X Evolution 3 upgrade #11 for iOS generator.




Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant