Created
January 31, 2013 12:29
-
-
Save joscandreu/4682535 to your computer and use it in GitHub Desktop.
Call tibar and titanium-barcode (barcode scanner modules for iOS & Android) in a consistent manner across multiple OS.
https://github.com/joseitinerarium/titanium-barcode
https://github.com/joseitinerarium/tibar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scanCode(successFunction, errorFunction){ | |
var titaniumBarcode = require('com.mwaysolutions.barcode'); | |
titaniumBarcode.scan({ | |
success:function(data) { | |
if(data && data.barcode) { | |
successFunction(data.barcode); | |
} else { | |
Ti.API.info("Error scanning barcode: " + data); | |
} | |
}, | |
error:function(err) { | |
errorFunction(err); | |
}, | |
cancel:function() { | |
Ti.API.info("ScanBarcode Canceled"); | |
}); | |
} | |
exports.scanCode = scanCode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scanCode(successFunction, errorFunction){ | |
var TiBar = require('tibar'); | |
TiBar.scan({ | |
// simple configuration for iPhone simulator | |
configure: { | |
classType: "ZBarReaderViewController", | |
sourceType: "Camera", | |
cameraMode: "Default", | |
symbol:{ | |
"QR-Code":true, | |
} | |
}, | |
success:function(data){ | |
Ti.API.info('TiBar success callback!'); | |
if(data && data.barcode){ | |
successFunction(data.barcode); | |
} | |
}, | |
cancel:function(){ | |
Ti.API.info('TiBar cancel callback!'); | |
}, | |
error:function(){ | |
errorFunction(); | |
} | |
}); | |
} | |
exports.scanCode = scanCode; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment