我正在使用Ionic 3,我刚刚添加了一个指纹插件
下面是代码段
import { FingerprintAIO } from "@ionic-native/fingerprint-aio/ngx";
constructor(private fingerPrintProvider : FingerprintAIO ){}
this.fingerPrintProvider.isAvailable().then((result)=>{
console.log(result);
if(result == 'finger' || result == 'face'){
//Fingerprint or Face auth available
console.log('Fingerprint or face exist!');
self.fingerPrintProvider.show({
clientId: 'RetraxFingerPrint',
clientSecret: 'RetraxFingerPrint', //Only necessary for Android
disableBackup: true, //Only for Android(optional)
localizedFallbackTitle: 'Use Pin', //Only for iOS
localizedReason: 'Please Authenticate' //Only for iOS
})
.then((result)=>{
console.log(result);
})
.catch((error) => {
//Fingerprint/Face was not successfully verified
console.log(error);
});
}
else {
//Fingerprint or Face Auth is not available
console.log("Fingerprint/Face Auth is not available on this device!")
}
})
RxJs版本如下所示
“ rxjs”:“ 5.5.2”
其他依赖性如下所示
"dependencies": {
"@angular/animations": "5.0.3",
"@angular/common": "5.0.3",
"@angular/compiler": "5.0.3",
"@angular/compiler-cli": "5.0.3",
"@angular/core": "5.0.3",
"@angular/forms": "5.0.3",
"@angular/http": "5.0.3",
"@angular/platform-browser": "5.0.3",
"@angular/platform-browser-dynamic": "5.0.3",
"@ionic-native/android-permissions": "^4.12.2",
"@ionic-native/badge": "^4.18.0",
"@ionic-native/camera": "^4.7.0",
"@ionic-native/core": "4.4.0",
"@ionic-native/crop": "^4.7.0",
"@ionic-native/deeplinks": "^4.6.0",
"@ionic-native/document-viewer": "^4.11.0",
"@ionic-native/file": "^4.7.0",
}
但是当我提供离子性服务时,我得到以下错误消息,这是依赖性问题还是代码有问题?
TypeError:Object(...)不是函数 在FingerprintAIO.isAvailable
Any help appreciated.
答案 0 :(得分:0)
您应该将插件的版本降级为@ 4。 从Ionic 3文档中:
$ ionic cordova plugin add cordova-plugin-fingerprint-aio
$ npm install --save @ionic-native/fingerprint-aio@4
并在没有/ngx
答案 1 :(得分:0)
您应该运行以下命令:
npm install @ionic-native/fingerprint-aio@5.22.0-beta-1