2016-05-12 24 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。如果您仍然有任何疑问,请在下面评论您的疑问。