离子指纹 android 给出缺少必需的参数错误

ionic finger print android giving missing required parameters error

我对 cordova 和 ionic 有点陌生,我正在构建一个简单的指纹认证应用程序。

我在 ionic 1 上使用 ionic native 的插件。它只有一个按钮,可以打开指纹验证对话框。但是无论我 运行 在什么设备上,它都会出错回调函数并给出错误消息 missing required parameters

我的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);
    })
}
});

提前致谢。

缺少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 获得了来源。

希望对您有所帮助,圣诞快乐!