2012-05-04 11 views
8

PhoneGap 1.7.0で動作するPhoneGapのBarcodeScanningプラグインを入手できた人は誰ですか?iOS PhoneGap 1.7.0 + Barcode Scanning Plugin issue

バーコードスキャニングプラグイン:https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner

問題そのが追加されたときにプラグインが設定されて取得されていないということです。..

私が呼ぶとき、私は次のことを得る「警告(window.plugins.barcodeScanner);」

「未定義」

私は..助けることができる人のため事前に

おかげでプラグインが追加されますし失敗していると私はより多くを知っていれば、質問を更新します孤立点しようとしています。以下..


更新答え:

答えて

6

OKこれで、PhoneGapプラグインを使用してTwitterを使って作業してみました。

Twitterの素敵な人たちがPhoneGap 1.7.0で動作するようにプラグインをアップデートしたので、これを私のアプローチの基礎として使用しました。

TwitterでのPhoneGapプラグイン:ここhttps://github.com/phonegap/phonegap-plugins/blob/master/iOS/Twitter/js/TwitterPlugin.js

更新barcodescanner.jsコードです:コルドバ2.3から

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

新しい名前を指摘してくれてありがとう:com.cordova.barcodeScanner。これをどうやって見つけましたか?
私はCordova.plistでそれを変更し、少なくともスキャナオブジェクトokを作成しました。 21時間前のファイルは依然としてorg.apache.cordovaを参照しています。barcodeScanner(https://github.com/phonegap/phonegap-plugins/blob/master/iOS/BarcodeScanner/barcodescanner.js)。 – GeorgeW

+1

@ damien murphy - 感謝の仲間、最終的に3日後に髪を引っ張る...;) –

11

優れ、

プラグインが再び機能するようになりました。
プラグインのマニュアルでは、Cordova.plistのキーがorg.apache.cordova.barcodeScannerである必要がありますが、明らかなことはまだcom.cordova.barcodeScannerであるはずです。

3

私だけ追加barcodescanner - それは

コピーした後、非常に簡単です必要なファイルはconfig.xmlに次の行を追加するだけです

具体 https://github.com/zeroasterisk/PhoneGap-BarcodeScanner-Example-iOS

(パスの一握りに)プラグインをインストールしたが働いたものを維持

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

はケースでは、これは誰もが役立ちます。機能を実証するための基本的なJSスキャナコードを実装しました。ロード時に自動実行、エラー時に自動リロード、成功/失敗/キャンセル時のアラート

注:barcodescanner.jsとindex.jsに関するコメントは、両方が必要/定義オブジェクトパスの私のカスタマイズに言及します。いくつかの順列の後、私はデモ/サンプルパスを動作させることができませんでした。

関連する問題