2016-05-12 61 views
1

我下載了這個插件Magnetic Card Reader感謝我有限的經驗我有問題。我使用square 3.5mm card reader根據作者的插件假設使用3.5mm讀卡器。根據文檔,我有這個代碼來啓動讀卡器。Phonegap讀卡器插件

$scope.start = function() { 

     function cardReaderStart(cardReadSuccess, cardReadFailure) { 
      console.log("Card reader started!"); 
      window.plugins.CardReaderPlugin.start(cardReadSuccess, cardReadFailure); 
     } 

     // If OS is Android 
     function cardReadSuccess(response) { 
      console.log("Card number:" + response[0].card_number); 

      if (typeof response[0].expiry_month != 'undefined' && response[0].expiry_month != null) { 
       console.log("Expiry month:" + response[0].expiry_month); 
      } 

      if (typeof response[0].expiry_year != 'undefined' && response[0].expiry_year != null) { 
       console.log("Expiry month:" + response[0].expiry_year); 
      } 
     } 

     //If OS is iOS 
     function cardReadSuccess(response) { 
      console.log("Card number:" + response['card_number']); 

      if (typeof response[0].expiry_month != 'undefined' && response[0].expiry_month != null) { 
       console.log("Expiry month:" + response['expiry_month']); 
      } 

      if (typeof response[0].expiry_year != 'undefined' && response[0].expiry_year != null) { 
       console.log("Expiry month:" + response['expiry_year']); 
      } 
     } 

     function cardReadFailure() { 
      console.log('Please try again!'); 
     } 

    }; 

問題是,當我點擊$ scope.start然後我繼續在方形卡片閱讀器中刷卡刷卡沒有任何反應。

我想知道我做錯了什麼?或者如果你們知道我可以使用任何其他讀卡器插件。

謝謝:)

+0

任何錯誤跟蹤?包含在HTML中的cordova.js文件?在deviceready事件中調用插件代碼? – Gandhi

回答

0

我寫了這個工作的代碼,請點擊Here,目前,它是完美的工作爲Android,不久我將要釋放的IOS。如果您仍然有任何疑問,請在下面評論您的疑問。