|
Project Information
Featured
Downloads
|
ZBar integration module for Titanium MobileDISCLAIMER This is a beta version, not meant for production. We are not professional Objective-C developers so there may will be better ways to approach this. If you want to contribute please email us. Special thanks goes to ZBar project and Appcelerator team. Tutorial - How to build a barcode reader enabled iPhone App within five minutes.PREREQUISITE
Step 1Module installation:
Step 2Create and run your App:
<modules>
<module version="0.x.x">tibar</module>
</modules> var win = Titanium.UI.createWindow({
title:'TiBar Test App',
backgroundColor:'#fff'
});
var TiBar = require('tibar');
var label = Titanium.UI.createLabel({
text:'TiBar App',
textAlign:'center',
width:'auto'
});
var button = Ti.UI.createButton({
title: "Scan barcode",
height:50,
width:250,
bottom:20
});
button.addEventListener('click', function(){
TiBar.scan({
// simple configuration for iPhone simulator
configure: {
classType: "ZBarReaderController",
sourceType: "Album",
cameraMode: "Default",
symbol:{
"QR-Code":true,
}
},
success:function(data){
Ti.API.info('TiBar success callback!');
if(data && data.barcode){
Ti.UI.createAlertDialog({
title: "Scan result",
message: "Barcode: " + data.barcode + " Symbology:" + data.symbology
}).show();
}
},
cancel:function(){
Ti.API.info('TiBar cancel callback!');
},
error:function(){
Ti.API.info('TiBar error callback!');
}
});
});
win.add(label);
win.add(button);
win.open();
TiBar Reader App How to test it in simulator?You can drag an image (or any other file, like a PDF) to the simulator, it will immediately open Safari and display the image. Save the image by Tapping and Holding on it. Now start TiBar Reader App, press Scan button and choose your barcode (NOTE: your barcode image have to be square). NOTE If you want to change default ZBar help notification, please edit zbar-help.html in Resources folder. Configuration// Configuration
// VC - ZBarReaderViewController - automatic capture
// C - ZBarReaderController - manually capture
var config = {
classType: "ZBarReaderController", // ZBarReaderViewController, ZBarReaderController
sourceType: "Album", // Library(C), Camera(VC), Album(C)
cameraMode: "Default", // Default, Sampling, Sequence
config:{
"showsCameraControls":true, // (VC)
"showsZBarControls":true,
"tracksSymbols":true, // the tracking rectangle that highlights barcodes
"enableCache":true,
"showsHelpOnFail":true,
"takesPicture":false
},
custom:{ // not implemented yet
"scanCrop":'',
"CFG_X_DENSITY":'',
"CFG_Y_DENSITY":'',
"continuous":''
},
symbol:{
"QR-Code":true,
"CODE-128":false,
"CODE-39":false,
"I25":false,
"DataBar":false,
"DataBar-Exp":false,
"EAN-13":false,
"EAN-8":false,
"UPC-A":false,
"UPC-E":false,
"ISBN-13":false,
"ISBN-10":false,
"PDF417":false
}
};This software uses the open source ZBar Barcode Reader library, version 1.1, which is available from http://zbar.sourceforge.net/iphone Changelog0.4.2
QRCode Barcode Video
To be continued...The source code and detailed description how we made the integration will follow soon. |