码迷,mamicode.com
首页 > 其他好文 > 详细

phonegap 二维码扫描插件使用

时间:2015-06-16 12:44:06      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:

 

phonegap  二维码扫描插件使用

文档地址 :   http://plugins.cordova.io/#/package/com.phonegap.plugins.barcodescanner

 

下载插件

 

cordova plugin add phonegap-plugin-barcodescanner

例子:

 

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:

   cordova.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 cordova.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:

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

 
 

phonegap 二维码扫描插件使用

标签:

原文地址:http://www.cnblogs.com/canghaixiaoyuer/p/4580215.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!