首页 > 解决方案 > 无法在 Ionic 4 中设置指纹选项 - 指纹 AIO

问题描述

我正在尝试在 Ionic 4 中使用 FingerPrint AIO 本机功能。我已按照指南(https://ionicframework.com/docs/native/fingerprint-aio)设置并运行它,但没有 FingerPrintOptions。

如果我像这样将“显示”对象保持为空: show({}) 它工作正常,但如果我尝试添加诸如:clientId、clientSecret 等选项,我会收到错误消息。

我有以下代码:

代码

this.faio.show({
    clientId: 'Fingerprint-Demo', 
    clientSecret: 'o7aoOMYUbyxaD23oFAnJ' 
    disableBackup:true,  
    localizedFallbackTitle: 'Use Pin', 
    localizedReason: 'Please authenticate'
})
.then((result: any) => console.log(result))
.catch((error: any) => console.log(error));

错误

ERROR in src/app/pages/login/login.page.ts(211,7): error TS2322: Type '{ clientId: string; clientSecret: string; disableBackup: true; localizedFallbackTitle: string; localizedReason: string; }' is not assignable to type 'FingerprintOptions'.
  Object literal may only specify known properties, and 'clientId' does not exist in type 'FingerprintOptions'.

目前,使用以下代码工作:

this.faio.show({})
.then((result: any) => console.log(result))
.catch((error: any) => console.log(error));

我究竟做错了什么?为什么我无法添加指纹选项?

没有fingerPrintOptions 的代码在Iphone 8(FingerPrint、Passcode)和Iphone X(Face ID)上工作和测试。

标签: ionic-frameworkionic4fingerprintface-id

解决方案


我在节点模块中检查了那些选项在 FingerprintOptions 中不可用,而是这是结构

this.faio.show({
     title: 'Biometric Authentication', // (Android Only) | optional | Default: "<APP_NAME> Biometric Sign On"
     subtitle: 'Coolest Plugin ever' // (Android Only) | optional | Default: null
     description: 'Please authenticate' // optional | Default: null
     fallbackButtonTitle: 'Use Backup', // optional | When disableBackup is false defaults to "Use Pin".
                                        // When disableBackup is true defaults to "Cancel"
     disableBackup:true,  // optional | default: false
 })
 .then((result: any) => console.log(result))
 .catch((error: any) => console.log(error));


推荐阅读