2016-12-24 59 views
1

我有點新來cordova &離子,我正在構建一個簡單的指紋認證應用程序。離子指紋android給丟失所需的參數錯誤

我使用離子1上的離子原生插件。它只會有一個打開指紋認證對話框的按鈕。但不管我跑什麼設備,它可將誤差回撥功能,並給予錯誤信息缺少必需的參數

我的index.html:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
    <title></title> 
    <link rel="manifest" href="manifest.json"> 
    <link href="lib/ionic/css/ionic.css" rel="stylesheet"> 
    <link href="css/style.css" rel="stylesheet"> 
    <script src="lib/ionic/js/ionic.bundle.js"></script> 
    <script src="www/lib/ngCordova/dist/ng-cordova.js"></script> 
    <script src="lib/ionic-native/ionic.native.js"></script> 
    <script src="cordova.js"></script> 
    <script src="js/app.js"></script> 
    </head> 
    <body ng-app="starter"> 
    <ion-pane> 
     <ion-header-bar class="bar-stable"> 
     <h1 class="title">Ionic Blank Starter</h1> 
     </ion-header-bar> 
     <ion-content ng-controller="ExampleController"> 
      <button class="button" ng-click="authenticate()">Authenticate</button> 
     </ion-content> 
    </ion-pane> 
    </body> 
</html> 

我app.js:

angular.module('starter', ['ionic', 'ionic.native']) 
.controller("ExampleController", function($scope, $cordovaAndroidFingerprintAuth) { 
    $scope.authenticate = function(){ 
    $cordovaAndroidFingerprintAuth.isAvailable(function(result) { 
     alert('finger print scanner is available'); 
    }, 
    function(message) { 
     alert("Cannot detect fingerprint device : "+ message); 
    }) 
} 
}); 

在此先感謝。

回答

0

ClientID屬性丟失,因爲它需要根據本機代碼中設置返回前一PluginResult對象:

 JSONObject resultJson = new JSONObject(); 

     // this checks clientId and throws an error if it was not set 
     if (!arg_object.has("clientId")) { 
      mPluginResult = new PluginResult(PluginResult.Status.ERROR); 
      mCallbackContext.error("Missing required parameters."); 
      mCallbackContext.sendPluginResult(mPluginResult); 
      return true; 
     } 

//一些代碼

 switch (mAction) { 
      // this code has not been reached 
      case AVAILABILITY: 
       resultJson.put("isAvailable",      isFingerprintAuthAvailable()); 
       resultJson.put("isHardwareDetected", mFingerPrintManager.isHardwareDetected()); 
       resultJson.put("hasEnrolledFingerprints", mFingerPrintManager.hasEnrolledFingerprints()); 
       mPluginResult = new PluginResult(PluginResult.Status.OK); 
       mCallbackContext.success(resultJson); 
       mCallbackContext.sendPluginResult(mPluginResult); 
       return true; 
      case ENCRYPT: 

我得到了來自here

希望它有助於聖誕快樂!

+0

謝謝@Blauharley我檢查了api文檔,發現isAvailable函數不會採用配置對象,因爲我看到你在git中提到的代碼,它在git中是不同的,最近一次提交聲明它是一個具有該函數的bug是固定的。現在我能夠正確使用它。 – Anand

+0

不客氣!是的,這很容易解決這個問題,但是你的問題並沒有這樣做,所以我沒有把這個插入到我的答案中,對不起...然而,結果很快樂! – Blauharley

相關問題