Use ZBar barcode reader with PhoneGap
Submitted by jeff on Mon, 12/13/2010 - 19:35.
ZBar and zxing are two iphone-compatible barcode reader libraries. I figured out how to integrate Zbar with PhoneGap for use as a QR code reader in my PhoneGap iphone application.
The process has a few major steps.
- Download and install PhoneGap.
- Setup a PhoneGap application in XCode
- Download and install Zbar.
- Follow the Zbar documentation to incorporate the SDK library into your PhoneGap
- Git the Zbar-PhoneGap plugin code (https://github.com/happyboredom/Zbar-PhoneGap-Plugin).
Using the Git
- Once you download the Git repository, copy the “ZbarPlug.h” and “ZbarPlug.m” files to the “Plugins” directory in your Xcode project.
- Copy “ZbarPlug.js” to your Project’s “www” directory.
- Link to the js file in your “index.html” file. Be sure to put it below the include for phonegap.js
cp ZbarPlug.h /path/to/xcode/project/Plugins cp ZbarPlug.m /path/to/xcode/project/Plugins cp ZbarPlug.js /path/to/xcode/project/www
<script type="text/javascript"
charset="utf-8"
src="ZbarPlug.js"></script>The example pops a javascript alert when a bar code or QR code have been decoded. Now you need to adapt the library to your project.
ZBar Barcode reader / QR code reader code for PhoneGap.
- View Gist for Zbar + PhoneGap
Recent blog posts
- Amazon S3 Website CNAME
- Button labels for checkout
- Insert html django contrib messages
- Twitter Bootstrap not working with LESS.js
- Javascript libs that offer basic subset of jquery features
- Building the donor-matic
- Playing with free Google Map alternatives.
- Some flows are not as complicated as they appear
- Form design crib sheet
- Script to get IE9 Windows Virtual PC images into Virtual Box