Make your web site, iOs or Android app
scan barcodes for free!

Quick links:

If you are an iPhone or Android developer who needs to incorporate barcode scanning into your app...

...you have at least three possibilities:

  • You develop your own barcode reader. Open source libraries like ZXing and ZBar are a great start, but they may not work on devices without autofocus or in difficult settings, such as when the barcode is not straight, at a weird angle, dimly lit, etc.
  • You license the pic2shop barcode scanner library and SDK. We spent thousands of hours to make it work quickly and accurately on all iPhone and Android models. Get more information here or from Vision Smarts' web site.
  • You take advantage of the pic2shop: custom URL scheme to launch pic2shop, read the barcode, and get the barcode digits back in your app, all for free. Android developers similarly use the Intent system to call pic2shop.

Below, we describe how to implement the third option on iOS. Web developers, you can use the same method to barcode enable your site, so read on!

This method requires that your users install pic2shop. However, pic2shop is, and will remain, free, so it does not cost you or your users anything. Moreover, pic2shop is lightweight (10MB), and loads very fast.

To start, the client app (your app) needs to check whether pic2shop is already installed:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"pic2shop:"]]) {
						

We use the result to show or hide the buttons that offer to install pic2shop or to scan a barcode.

To take the user to the pic2shop install page do:

NSURL *urlapp = [NSURL URLWithString:
@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=308740640&mt=8"];
[[UIApplication sharedApplication] openURL:urlapp];				
						

To start pic2shop, and tell it to call back the client app with the barcode (your app will exit or be suspended at this point !):

NSURL *urlp2s = [NSURL URLWithString:@"pic2shop://scan?callback=p2sclient%3A//EAN"];
[[UIApplication sharedApplication] openURL:urlp2s];			
						

The part after "callback=" is the (escaped) URL that pic2shop will use to call back your app. You can change it, but you need to keep the "EAN" string somewhere, because pic2shop will replace it with the barcode digits.

Web developers, the above link is all you have to do to integrate barcode scanning in your site. In your case, the callback will be a regular URL pointing to your web app.

For the callback to work, your app needs to have registered its own URL scheme with the iPhone OS. For that, it needs to add an entry in its own Info.plist (we use the p2sclient: scheme in this example):

And finally, when it is restarted, your app needs to detect that it has been called back, and extract the barcode information from the callback URL. That is done by defining the handleOpenURL() method of the App Delegate:

- (BOOL)application:(UIApplication *)application  handleOpenURL:(NSURL *)url 
{
  NSLog(@"got barcode: %@", [url host]); 
}
						

In this simple example, the barcode is the "host" part of the URL, right after the double slash.

That's it! Have a lot of fun with barcodes! We would love to hear about the apps that you build using this system.

pic2shop is developed by Vision Smarts

For more information, visit our website at www.visionsmarts.com.

Download pic2shop

Fast. Easy. Independent. Private.
Give it a try now!