Search code examples
web-servicesmobilebarcode-scanner

Scan barcodes from a mobile web site?


What is the best solution to scan barcodes and QR codes from a mobile web site (no phonegap etc...)? The solution has to work on Android, iOS and Windows Phone.

I've heard about pic2shop, does it work well (even on windows phone)? Are there better solutions?


Solution

  • As nothing seems to come out, I'll explain the best solution I found.

    The thing is to use the app "pic2shop". It is a barcode scanning app that is available on Android, iOS and Windows Phone 8. It is possible to request this app from a web page, let it scan the barcode and then callback you web site with the scanned information.

    window.location="pic2shop://scancallback=http%3A//www.google.com/m/
    products%3Fg‌l%3Dus%26source%3Dmog%26hl%3Den%26source%3Dgp
    2%26q%3DEAN%26btnProductsHome%3DSear‌​ch%2BProducts
    

    The above example will open the app and when the user scans a barcode, open the web browser on a google search for the scanned product barcode.

    If pic2shop is not installed on the phone, the call will fail. The thing is to set a timeout that will redirect to the store (to download the app) if the call fails. User agents can be used to know to which store it should redirect.

    Full example (Android store redirection) :

    <SCRIPT LANGUAGE="JavaScript">
             function trygoogle() {
              setTimeout(function() {
              // if pic2shop not installed yet, go to App Store
              window.location = "market://details?id=com.visionsmarts.pic2shop";
             }, 25);
             // launch pic2shop and tell it to open Google Products with scan result
             window.location="pic2shop://scan?callback=http%3A//www.google.com/m/products%3Fgl%3Dus%26source%3Dmog%26hl%3Den%26source%3Dgp2%26q%3DEAN%26btnProductsHome%3DSearch%2BProducts";
             }
    </SCRIPT>
    

    Documentation : http://www.pic2shop.com/developers.html