- A custom virtual keyboard app with a built-in scanner (currently on android only)
- A dedicated scanner app with an API based on special URLs (currently on android only)
- A separate bluetooth barcode scanner (see previous post)
Perhaps, the easiest method to start with, is an app called "Barcodescanner Keyboard" - a custom keyboard for Android devices with built-in support for reading barcodes via the main camera. There is a free add-supported version available on Google Play and the full version is available at merely 3,59€. The app works just like any other on-screen keyboard, but it has a separate button to activate the camera. Once a barcode was read, it is "typed" just like regular keyboard input. Thus, you can easily use it with any app, web page - anywhere. No need to code anything!
The downside of this approach is, that you still need to tap on an editable field, let the keyboard pop up, press the camera button on the keyboard, etc. It is not a one-click solution. Apart from that, you have to ensure, the user uses exactly this keyboard. Otherwise your app won't have any barcode support. Finally, the actual keyboard is clearly not one the best. It does support different languages, but it looks pretty ugly an works far not as smooth as the default android keyboard, for example. Of course, being a keyboard is not the primary focus of the app, but you will have to keep in mind, that the actual typing will get more cumbersome.
Unfortunately, I have not found such an app for iOS, so this idea only works for Android at the moment.
Another fairly simple approach - also utilizing third-party applications - is based on the app called "Barcode Scanner". This is a dedicated scanner app and a very good one. It offers a special API for scanning from web applications. All you need to do, is add a link or button to your application, with a special URL. Clicking on it will open the scanner app, just like clicking on a facebook-link opens the facebook app on your smartphone. The URL has different parameters including the desired barcode types and a callback URL, which will get opened once a barcode is read. The barcode is then passed to the callback URL as one of the parameters.
Generally this works very well. The scanner app gets started very quickly and works great, but you cannot control the way the callback URL is opened: it will probably get opened in the default browser, no matter which browser you used initially. This is especially uncomfortable, if you were using webview or kiosk mode (a Link to your web app from the home screen) - after scanning the barcode you will get redirected to a browser, not the orignal webview instance.
Unfortunately, the scanner app seems not to be available on iOS anymore. However even the original iOS-Version used a different format of the URL to call the app than the android one. This makes this approach not really universal. On Android you also need to take into account, that pressing the back button will direct you to the scanner app first and only then to the page previously viewed.
Reading barcodes from a mobile web application can be really simple thanks to some helper-apps available on the market. However, that approach forces to install a specific app on the target mobile device. Additionally, there are far less options on iOS than on android. I have not looked for windows mobile apps specifically, but I've also not come across any of them while searching - I assume, there are very few or even none.