An Appcelerator Titanium module that creates a view that allows you to scan UPC's using the ZBar Barcode Reader (http://zbar.sourceforge.net/).
I had been playing around with the Acktie Barcode reader and really wanted something that would let me place the view inside of my own page (and not use a modal window). This module allows you to create the barcode view just as you would create a standard Titanium.UI.view and listen for a 'success' callback.
This module will continue to grow and new options will be added in the near future.
Include the module in your tiapp.xml:
com.mfogg.barcode
Currently the options you have are limited to what type of barcodes you would like to 'listen' for, but that makes the module pretty simple :)
The types of barcodes available are:
- EAN2
- EAN5
- EAN8
- UPCE
- ISBN10
- UPCA
- EAN13
- ISBN13
- COMPOSITE
- I25
- DATABAR
- DATABAR_EXP
- CODE39
- PDF417
- CODE93
- CODE128
And they can be used like...
var Barcode = require('com.mfogg.barcode'); // Initialize the Barcode module
// open a single window
var win = Ti.UI.createWindow({backgroundColor:"#eee"});
var allowed_upcs = [ // See list of available barcode types above
"UPCE",
"ISBN10",
"UPCA",
"EAN13",
"CODE93",
"CODE128"
];
var barcodeView = Barcode.createView({
top: 0,
height: 320,
width: 320,
barcodes: allowed_upcs
});
win.add(barcodeView);
win.open();
- Note here that the created view (ex. 'barcodeView' above) can have other views added on top of it to act as a camera overlay (exactly how you would a standard Ti.UI.view)
Currently, the only event listener enabled is "success" which will fire every time a barcode that fits the types above comes into the view.
barcodeView.addEventListener("success", function(event){
// event.data == number returned from the scan
// event.type == type of scan
Ti.API.info("[NEW SCAN] Data: "+event.data);
Ti.API.info("[NEW SCAN] Type: "+event.type);
});
- Ability to manage the light on/off (on initialize and via function call).
- Android support
... anything else :)
Do whatever you want, however you want, whenever you want. And if you find a problem on your way, let me know so I can fix it for my own apps too :)- https://github.com/acktie/Acktie-Mobile-iOS-Barcode-Reader - Got a lot of inspiration from what these guys did.
- http://zbar.sourceforge.net/ - ZBar Barcode Reader