This plugin has been moved to phonegap-plugin-barcodescanner. Please use that repository for future development. Starting from version 4.0.0, it is a cross platform plugin with support for BlackBerry 10
This plugin scans all types of barcodes supported by the ZXing library. The Rear Camera is used and it shows the camera's viewfinder for the user to target the barcode.
This API can be installed from source or from the Cordova Plugin Registry. Installation from the registry is done through the following:
cordova plugin add com.blackberry.community.barcodescanner
or,
webworks plugin add com.blackberry.community.barcodescanner
Installation from source is the same but instead of the id ("com.blackberry.community.barcodescanner"), use the file system path to the source plugin folder.
This feature depends on the blackberry.io which is installed with it.
Permission for the camera is required, so a permission check will automatically be added to your application, and the user will be prompted to allow it.
When you start scanning, you can make the experience better for your users with the Prevent Sleep Extension. If you include Prevent Sleep in your app, the BarcodeScanner will automatically use it as needed to keep the screen on. Instructions for installing are in the Prevent Sleep README
/* Start scanning for barcodes.
* @param succ
* Function that executes when the barcode has been recognized
* successfully. Expected signature: succ(read_data), where
* read_data is a string.
* @param fail
* Function that executes when the barcode has not been recognized
* successfully. Expected signature: fail(error_message),
* where error_message is a string.
*/
app.barcodeScanner.startRead(succ, fail)
/*
* Stop scanning for barcodes.
* @param succ
* Function that executes when the barcode has been stopped
* successfully. Expected signature: succ(stopped_notification), where
* stopped_notification is a string.
* @param fail
* Function that executes when the barcode could not be
* successfully stopped. Expected signature: fail(error_message),
* where error_message is a string.
*/
app.barcodeScanner.stopRead(succ, fail)
For Cordova Projects:
- Create a new project using
cordova create
. - Copy the www folder in the sample directory over the default one created by that command.
- Run
__bbndk-env.bat
orbbndk-env.sh
script if the NDK is not on your PATH. - Add the blackberry10 platform to your project by running
cordova platform add blackberry10
. - Then add the BarcodeScanner plugin to the project using
cordova plugin add /path/to/project/plugin
- Finally, execute
cordova run
For WebWorks 2.0 projects:
- Create a new project using
webworks create
. - Copy the www folder in the sample directory over the default one created by that command.
- Then add the BarcodeScanner plugin to the project using
webworks plugin add /path/to/project/plugin
- Finally, execute
webworks run
Please take note that this plugin does not work on a simulator.
This plugin is Open Source licensed under the Apache 2.0 License
Jasmin Auger, Alex Tough and Tim Windsor.
Based on code written by Alex Kwan, and Mike Delong
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.