2012-05-04 38 views
8

Có ai quản lý để nhận plugin BarcodeScanning cho PhoneGap hoạt động trên PhoneGap 1.7.0 không?iOS PhoneGap 1.7.0 + Quét mã vạch Sự cố plugin

quét mã vạch plugin: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner

Những vấn đề là các plugin là không nhận được thiết lập khi nó bị như ..

tôi nhận được sau khi tôi gọi là "alert (window.plugins.barcodeScanner);"

"không xác định"

Tôi cố gắng để cô lập các điểm mà các plugin là không để gia tăng và sẽ cập nhật các câu hỏi một lần tôi biết thêm ..

Cảm ơn trước cho bất cứ ai có thể giúp đỡ. ..


câu trả lời Cập nhật dưới đây:

Trả lời

6

OK vì vậy sau một chút poking xung quanh và sử dụng plugin PhoneGap twitter như một ví dụ tôi quản lý để làm cho nó hoạt động !!

Tôi đã sử dụng điều này làm cơ sở cho cách tiếp cận của mình vì những người đáng yêu tại twitter đã cập nhật plugin của họ để làm việc với PhoneGap 1.7.0 cảm ơn Chúa !!

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

Đây là barcodescanner.js đang được cập nhật:

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(); 
         }); 
+0

cảm ơn vì đã chỉ ra tên mới: com.cordova.barcodeScanner. Làm thế nào bạn tìm thấy điều này?
Tôi đã thay đổi nó trong Cordova.plist và ít nhất nó tạo ra đối tượng máy quét ok. Lưu ý rằng tệp cũ 21 giờ vẫn được tham chiếu org.apache.cordova.barcodeScanner tại https://github.com/phonegap/phonegap-plugins/blob/master/iOS/BarcodeScanner/barcodescanner.js. – GeorgeW

+1

@damien murphy - cảm ơn bạn đời, cuối cùng sau 3 ngày tóc kéo nó hoạt động ...;) –

11

Tuyệt vời,

Plugin hiện hoạt động trở lại.
Một vấn đề là tài liệu cho plugin vẫn cho biết khóa trong Cordova.plist phải là org.apache.cordova.barcodeScanner nhưng điều hiển nhiên bây giờ phải là com.cordova.barcodeScanner.

3

tôi chỉ cần thêm barcodescanner để cordova 2.3 - nó khá đơn giản

sau khi sao chép các tệp cần thiết mà bạn chỉ cần thêm dòng sau vào config.xml

<plugin name="org.apache.cordova.barcodeScanner" value="CDVBarcodeScanner" /> 
0

Trong trường hợp này giúp bất cứ ai: https://github.com/zeroasterisk/PhoneGap-BarcodeScanner-Example-iOS

Cụ thể:

cài đặt plugin (trong một số ít các đường dẫn) nhưng vẫn giữ một mà làm việc. Đã triển khai mã máy quét JS cơ bản để thể hiện chức năng: tự động chạy khi tải, tự động tải lại lỗi, cảnh báo về thành công/lỗi/hủy.

LƯU Ý: các nhận xét trên barcodescanner.js và index.js, cả hai đều đề cập đến tùy chỉnh của tôi về đường dẫn đối tượng xác định/yêu cầu. Tôi không thể có được các đường dẫn demo/ví dụ để làm việc, sau một số hoán vị.

Các vấn đề liên quan