iOS PhoneGap 1.7.0 +条形码扫描插件问题

dam*_*hy. 8 barcode-scanner ios phonegap-plugins cordova

有没有人设法让PhoneGap的BarcodeScanning插件在PhoneGap 1.7.0上运行?

条码扫描插件:https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner

问题是插件在添加时没有设置..

当我调用"alert(window.plugins.barcodeScanner);"时,我得到以下内容.

"不确定"

我试图隔离插件未能添加的点,并且一旦我知道更多就会更新问题..

提前感谢任何可以提供帮助的人...


更新的答案如下:

小智 11

很好,

插件现在再次运行.
一个问题是插件的文档仍然说Cordova.plist应该是关键应该是org.apache.cordova.barcodeScanner显而易见的事情com.cordova.barcodeScanner.


dam*_*hy. 6

好吧,经过一番探索,并使用twitter PhoneGap插件作为一个例子,我设法让它工作!

我用它作为我的方法的基础,因为可爱的人在Twitter更新了他们的插件与PhoneGap 1.7.0工作感谢上帝!

Twitter PhoneGap插件: https ://github.com/phonegap/phonegap-plugins/blob/master/iOS/Twitter/js/TwitterPlugin.js

这是更新的barcodescanner.js代码:

var BarcodeScanner = function(){};

BarcodeScanner.prototype.isBarcodeScannerAvailable = function(response){
    cordova.exec(response, null, "BarcodeScannerPlugin", "isBarcodeScannerAvailable", []);
};

BarcodeScanner.prototype.isBarcodeScannerSetup = function(response){
    cordova.exec(response, null, "BarcodeScannerPlugin", "isBarcodeScannerSetup", []);
};

//-------------------------------------------------------------------
BarcodeScanner.Encode = {
TEXT_TYPE:     "TEXT_TYPE",
EMAIL_TYPE:    "EMAIL_TYPE",
PHONE_TYPE:    "PHONE_TYPE",
SMS_TYPE:      "SMS_TYPE",
CONTACT_TYPE:  "CONTACT_TYPE",
LOCATION_TYPE: "LOCATION_TYPE"
}

//-------------------------------------------------------------------
BarcodeScanner.prototype.scan = function(success, fail, options) {
    function successWrapper(result) {
        result.cancelled = (result.cancelled == 1)
        success.call(null, result)
    }

    if (!fail) { fail = function() {}}

    if (typeof fail != "function")  {
        console.log("BarcodeScanner.scan failure: failure parameter not a function")
        return
    }

    if (typeof success != "function") {
        fail("success callback parameter must be a function")
        return
    }

    if ( null == options ) 
        options = []

        return PhoneGap.exec(successWrapper, fail, "com.cordova.barcodeScanner", "scan", options)
        }

//-------------------------------------------------------------------
BarcodeScanner.prototype.encode = function(type, data, success, fail, options) {
    if (!fail) { fail = function() {}}

    if (typeof fail != "function")  {
        console.log("BarcodeScanner.scan failure: failure parameter not a function")
        return
    }

    if (typeof success != "function") {
        fail("success callback parameter must be a function")
        return
    }

    return PhoneGap.exec(success, fail, "com.cordova.barcodeScanner", "encode", [{type: type, data: data, options: options}])
}

cordova.addConstructor(function() {

                       /* shim to work in 1.5 and 1.6  */
                       if (!window.Cordova) {
                       window.Cordova = cordova;
                       };


                       if(!window.plugins) window.plugins = {};
                       window.plugins.barcodeScanner = new BarcodeScanner();
                       });
Run Code Online (Sandbox Code Playgroud)