I created a full implementation of a phonegap barcode scanner app using the ionic and angularjs frameworks for the platforms supported by com.phonegap.plugins.barcodescanner. The platforms supported are Android, iOS and Windows Mobile. It is available from github: https://github.com/jlinoff/PgBarcodeScanner.git.
The app has some interesting features like using the $q promise/deferred implementation to capture the barcode scanner information for display in a table, using the angularjs state routing that is the default in the ionic framework and providing the config.xml that phonegap needs to incorporate the plugin properly.
To use it in phonegap, create a new, open-source project and reference this github repository (or your fork). Phonegap knows how to deal with the www directory tree automatically.
The app has not been fully tested so please beware. It is only meant to show the basic ideas so that you can easily incorporate the barcode scanner into your app.
The source code is distributed under the MIT license so you are free to use it any way that you like.
I built the app using the following commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
$ cd work/apps $ ionic state PgBarcodeScanner tabs $ cd PgBarcodeScanner $ cordova plugin add http://github.com/phonegap-build/BarcodeScanner.git # add the plugin $ edit config.xml # add in the plugin reference $ cp config.xml www/ $ ionic platform add android $ ionic platform add ios $ cd www $ touch templates/tab-about.html $ touch templates/tab-scan.html $ # edit the source files $ open -a brackets index.html templates/*html js/*.js $ # remote the initialization cruft $ rm -f templates/friend* templates/tab-friends.html \ templates/tab-dash.html templates/tab-accounts.html $ # compile and test $ ionic build android ios $ # use the new ripple: http://ripple.incubator.apache.org/ $ # npm install -g ripple-emulator $ ripple emulate |