我对Cordova& amp;离子和我正在构建一个简单的指纹认证应用程序。
我在离子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 :(得分: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获得了来源。
希望它有所帮助,圣诞快乐!