Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
[readme]
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Willoughby committed Oct 24, 2012
1 parent 89ed372 commit 9211290
Showing 1 changed file with 58 additions and 4 deletions.
62 changes: 58 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,71 @@
BarcodeScanner
==============

cross-platform BarcodeScanner for Cordova / PhoneGap
Cross-platform BarcodeScanner for Cordova / PhoneGap.

follows the Cordova Plugin spec https://github.com/alunny/cordova-plugin-spec

so that it works with Pluginstall https://github.com/alunny/pluginstall
Follows the [Cordova Plugin spec](https://github.com/alunny/cordova-plugin-spec), so that it works with [Pluginstall](https://github.com/alunny/pluginstall).

Note: the Android source for this project includes an Android Library Project.
pluginstall currently doesn't support Library Project refs, so its been
prebuilt as a jar library. Any updates to the Library Project should be
committed with an updated jar.

## Using the plugin ##
The plugin creates the object `window.plugins.barcodeScanner` with the method `scan(success, fail)`.
The following barcode types are currently supported:

* QR_CODE
* DATA_MATRIX
* UPC_E
* UPC_A
* EAN_8
* EAN_13
* CODE_128
* CODE_39
* CODE_93
* CODABAR
* ITF
* RSS14
* PDF417
* RSS_EXPANDED

`success` and `fail` are callback functions. Success is passed an object with data, type and cancelled properties. Data is the text representation of the barcode data, type is the type of barcode detected and cancelled is whether or not the user cancelled the scan.

A full example could be:

window.plugins.barcodeScanner.scan( function(result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}, function(error) {
alert("Scanning failed: " + error);
}
);

## Encoding a Barcode ##
The plugin creates the object `window.plugins.barcodeScanner` with the method `encode(type, data, success, fail)`.
Supported encoding types:

* TEXT_TYPE
* EMAIL_TYPE
* PHONE_TYPE
* SMS_TYPE

A full example could be:

window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
alert("encode success: " + success);
}, function(fail) {
alert("encoding failed: " + fail);
}
);

## Thanks on Github ##

So many -- check out the original [iOS](https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner) and [Android](https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner) repos.


## Licence ##

The MIT License
Expand Down

0 comments on commit 9211290

Please sign in to comment.