ionic finger print android giving missing required parameters error

862 views Asked by At

I am bit new to cordova & ionic and I am building a simple fingerprint authentication app.

I am using the plugin from ionic native on ionic 1. It will just have a button which will open the fingerprint authentication dialog. but on no matter what device I run it is going to error call back function and giving error message missing required parameters

my 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>

My 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);
    })
}
});

Thanks in advance.

1

There are 1 answers

2
Blauharley On BEST ANSWER

The clientId property is missing, as it is required to be set according to this native code before a PluginResult Object is returned:

        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;
        }

// some code

        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:

I got the source from here.

Hope it helps and merry christmas!