简体   繁体   中英

TypeError: Object(...) is not a function while using fingerprint plugin in ionic 3

I am working with Ionic 3 and i just added a Fingerprint plugin

Reference : Fingerprint AIO Plugin

And the code snippet is shown below

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 version is shown below

"rxjs": "5.5.2"

Other Dependencies shown below

"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",
    }

But when i do ionic serve i get this below error, Is it a dependency issue or any issue with the code ?

TypeError: Object(...) is not a function at FingerprintAIO.isAvailable

Any help appreciated.

You should downgrade version of plugin to @4.. From Ionic 3 documentation:

$ ionic cordova plugin add cordova-plugin-fingerprint-aio 
$ npm install --save @ionic-native/fingerprint-aio@4

And also export without /ngx

https://ionicframework.com/docs/v3/native/fingerprint-aio/

你应该运行这个命令:

npm install @ionic-native/fingerprint-aio@5.22.0-beta-1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM