SocketMobile Scanner : How to detect barcode or QR get scanned?

151 Views Asked by At

I am using SocketMobile scanner 7Xi in SPP(Application Mode) for iOS app. I have integrated the scanapisdk SDK.

On scanning Barcode or QR code below delegate is called :

- (void) onDecodedDataResult:(long)result device:(DeviceInfo *)device decodedData:(ISktScanDecodedData*)decodedData { NSString * scannedText = [NSString stringWithUTF8String:(const char *)[decodedData getData]]; }

Here, how would I get to know if scan happened on Barcode or QR ?

I want to detect whether Barcode or QR was scanned.

Is it possible ?

1

There are 1 best solutions below

0
Enrico On BEST ANSWER

ISktScanDecodedData has two methods which you could use to determine the barcode type

  • getSymbologyID - returns an int
  • getSymbologyName - returns a string

I'd recommend using the first one, because the name is subject to change.

- (void) onDecodedDataResult:(long)result device:(DeviceInfo *)device decodedData:(ISktScanDecodedData*)decodedData
{
    NSString * scannedText = [NSString stringWithUTF8String:(const char *)[decodedData getData]];
    int symbologyId = [decodedData getSymbologyID];

    if (symbologyId == ISktScanSymbology.id.kSktScanSymbologyQRCode) {
        // do something
    } else if (symbologyId == /* INSERT "BARCODE" SYMBOLOGY ID HERE */ ) {
        // do something else
    }
}

If by "barcode" you mean any linear barcode (a.k.a one-dimensional barcode), you will need to specify all the different types of linear barcodes in your code