Skip to main content

ProGlove Documentation

Initiate a scanning event

Set the Scanner Delegate

When a scanner starts connecting, set the delegate so you can receive barcodes as soon as they arrive (barcodes may arrive during discovery when the central is restoring).

To set the scanner delegate, confirm the PGPeripheralDelegate protocol and set the delegate property.

Example 110. Objective C
…
@interface ViewController () <PGPeripheralDelegate>
…
- (void)centralManager:(PGCentralManager *)centralManager connectingToScanner:(PGPeripheral *)scanner {
  scanner.delegate = self;
}


Example 111. Swift
…
class ViewController: UIViewController, PGPeripheralDelegate {
…
func centralManager(_ centralManager: PGCentralManager, connectingToScanner scanner: PGPeripheral) {
  scanner.delegate = self
}


Initiate a scan

When you scan a barcode, the PGPeripheralDelegate delegate method peripheral:didScanBarcodeWithResult: is called and the PGScannedBarcodeResult object, containing the scan content and scan symbology, is retrieved:

Example 112. Objective C
- (void)peripheral:(nonnull PGPeripheral *)peripheral didScanBarcodeWithResult:(nonnull PGScannedBarcodeResult *)result {
  NSLog(@"Barcode scanned: %@", result.barcodeContent);
  if (result.barcodeSymbology){
    NSLog(@"Barcode symbology: %@", result.barcodeSymbology);
  }
}


Example 113. Swift
func peripheral(_ peripheral: PGPeripheral, didScanBarcodeWith data: PGScannedBarcodeResult) {
  print("Barcode scanned: \(data.barcodeContent)")
  if let symbology = data.barcodeSymbology {
    print("Barcode symbology: \(symbology)")
  }
}