The WVScan JavaScript API lets you launch a QR code or bar code scanner from HTML5 apps and miniapps.
WVScan.scan
This API requires WindVane Android 1.0.3.4 or later, or WindVane iOS 2.1.4 or later.
Launches the code scanner. Results are delivered via both a direct callback and DOM events — register event listeners before calling the API.
Sample code
document.addEventListener('WVScan.Event.scanSuccess', function (e) {
alert('event scanSuccess: ' + JSON.stringify(e.param));
});
document.addEventListener('WVScan.Event.scanFailed', function (e) {
alert('event scanFailed: ' + JSON.stringify(e.param));
});
var params = {
openFlight: true,
title: 'XXX'
};
window.WindVane.call('WVScan', 'scan', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
Input parameters
|
Parameter |
Type |
Required |
Description |
|
openFlight |
boolean |
No |
Specifies whether to enable the flash. |
|
title |
string |
No |
The title of the scanning page. Default: |
|
compatible |
boolean |
No |
Set to |
[
boolean]openFlight: optional. Specifies whether to enable the flash.trueenables the flash;falsedisables it. Default:false.[
string]title: optional. The title of the scanning page. Default:"scan QR code or bar code".[
boolean] compatible: optional. Set totruewhen calling this API after a miniapp is presented.
Callback parameters
Success callback:
No callback parameters. Use the
WVScan.Event.scanSuccessDOM event to retrieve the scan result.
Failure callback:
[
string]msg: the error message.
Event listening
WVScan.Event.scanSuccess: The code is scanned.
Event parameters:
[
string]content: the decoded content of the scanned code.-
[
string]format: the bar code format. Valid values:[
string]QR_CODE: QR code.[
string]AZTEC: Aztec 2D bar code.[
string]CODABAR: Codabar bar code.[
string]CODE_39: Code 39 bar code.[
string]CODE_93: Code 93 bar code.[
string]CODE_128: Code 128 bar code.[
string]DATA_MATRIX: Data Matrix 2D bar code.[
string]EAN_8: EAN-8 bar code.[
string]EAN_13: EAN-13 bar code.[
string]ITF: Interleaved 2 of 5 (ITF) bar code.[
string]MAXICODE: MaxiCode hexagonal 2D bar code.[
string]PDF_147: PDF417 2D bar code.[
string]RSS_14: RSS 14 bar code.[
string]RSS_EXPANDED: RSS Expanded bar code.[
string]UPC_A: UPC-A bar code.[
string]UPC_E: UPC-E bar code.
WVScan.Event.scanFailed: Code scanning failed.
Event parameters:
[
string]msg: the error message.
Supported bar code formats
|
Enum value |
Format |
Type |
|
|
QR code |
2D |
|
|
Aztec |
2D |
|
|
Data Matrix |
2D |
|
|
PDF417 |
2D |
|
|
MaxiCode |
2D |
|
|
Code 39 |
1D |
|
|
Code 93 |
1D |
|
|
Code 128 |
1D |
|
|
Codabar |
1D |
|
|
Interleaved 2 of 5 (ITF) |
1D |
|
|
EAN-8 |
1D |
|
|
EAN-13 |
1D |
|
|
UPC-A |
1D |
|
|
UPC-E |
1D |
|
|
RSS 14 |
1D |
|
|
RSS Expanded |
1D |