iOS Barcode Scanner

Are there any free or paid barcode scanner controls/classes/declares available for Xojo iOS?

I looked thru the forums and the downloaded example project I’ve kept and I can’t seem to find any… :frowning:

I have yet to write any iOS apps in Xojo, so I can’t directly answer your question. But I’ve done barcode scanning apps for iOS using other tools so I can give you a little more perspective.

Hardware barcode scanners you can use with iOS will fall into two broad categories:

  1. HID (Human Interface Device): these will mimic a bluetooth keyboard
  2. Scanners that require a vendor SDK to integrate with your project

The HID based scanners don’t necessarily require anything different in your code. The barcode contents just gets “typed” into the field with the focus. But that is also one of its drawbacks. If there is only a single input field on your form, you can programmatically help keep the focus there for the sake of scans. Once the UI gets more complicated, HID scanners can be a royal pain to the user. Also, the more text in the barcode the slower it “types” into the form. (A progressively bigger problem for 2D codes that can hold more data.)

It also means while “connected” the iOS device thinks you are using an external keyboard so the on-screen keyboard is disabled. So the “better” bluetooth scanners will include a button to let the user connect/disconnect at will to allow them to use the iOS keyboard.

IMHO, these are not a very user friendly solution – but perhaps can be effective in certain scenarios.

Lots of bluetooth scanners also support SPP (Serial Port Profile) mode, which in theory lets you just get notified when there is a scan and intelligently handle it in your code without regard to what has the iOS input focus (if anything). The problem is iOS does not support SPP, so you can only do SPP with Android or desktop app, etc.

That leaves you with hardware scanners that have gone through Apple hardware MFi certification and can offer deeper app integration via a SDK. Two that I know of are Linea Pro and Socket Mobile . Both offer (that is, require) SDKs to integrate into your app. I don’t know that either has Xojo examples.

Still a third option is doing barcode scans using the internal camera. In my experience by FAR the best is a SDK from Scandit but depending on your usage the terms are not cheap. There are also freeware SDKs; two which I have used previously are Zxing and Zbar. Neither comes anywhere close to the performance of Scandit, which quite frankly works amazingly well.

But I have not used any of them with Xojo.

Barcode scanning is what got me into iOS programming, but I think that was around iOS4.

you can use any bluetooth barcode scanner the problem is to show the keyboard if you find any way to show the keyboard without discoonect the barcode scanner then it works for you

You should look at Jason king’s classes. He did qrcode scanning the first year ios was out and we used it for the xdc registration system.

Reading QR codes is one case where you can get reasonable performance from camera scans without needing a more robust SDK like Scandit (which I prefer for fast UPC and EAN scans).

It looks like Jason’s classes are here

Indeed checkout out the example project → AVFoundation folder and there is an example of how to do this.

Thank you everyone! I’m not sure why I couldn’t find it…

Thank you @Jason King ! I just tried the AVFoundation Barcode Scan demo and it works very quickly!

Hi Jason,

I have looked at your BarcodeScannerView example in the AVFoundationViews section, and it works beautifully. However, I don’t seem to be able to capture the text from a QRCode, rather than have it displayed in the GenericView1 container. I want to be able to capture what is scanned as text, and react to it accordingly.

If you could please point me in the right direction I would appreciate it.

Cheers.
Bobby

That project has two barcode scanner examples. One easy to find which requires taking a pic and the other that scans by pointing.

Hi Bobby,

In the example project, the following line in the HandleMetadataOutputObjs function sets a label with the text contained in the QRCode:

performSelectorOnMainThread(Label1.Handle,NSSelectorFromString("setText:"),metadataObj.stringValue,False)

Basically, the function is called on a non-Xojo managed thread. You should be able to simply save it to a variable in this function, but do not do any comparisons with its value in this function to make logic decisions. Instead, set a timer which watches the variable you will be setting for a change and then make your decision then. If you try to use the callback function, your app may crash randomly.

Hopefully this helps.

Here is what I’m doing in the HandleMetadataOutputObjs function in one of my iOS apps that reads an IP address from a QR code and uses that to connect to a remote computer. It sets a global variable (probably not the best way of accomplishing this) that is later used to establish the connection once the barcode scanner view closes.

  #Pragma Unused sender
  #Pragma Unused output
  #Pragma Unused connection
  
  if metadataObjects.Count > 0 then
    dim metadataObj as new AVFoundation.AVMetadataMachineReadableCodeObject( metadataObjects.Value(0) )
    
    if metadataObj.type = "org.iso.QRCode" then
      StopReading
      App.scannedIP = metadataObj.stringValue
      Self.Close
    end if
  end if

I hope that helps.

Hi Jason,

Worked perfectly, thank you so much.

Thanks to all who responded, too.

Cheers.
Bobby

Check out the demo on github. It has a fully working example