|
@@ -1,38 +1,22 @@
|
|
|
import { BiometricAuth, AndroidBiometryStrength } from '@aparajita/capacitor-biometric-auth';
|
|
|
|
|
|
-export const verifyFingerprint = async()=> {
|
|
|
+export const verifyFingerprint = async () => {
|
|
|
try {
|
|
|
- // const available = await BiometricAuth.isAvailable();
|
|
|
- // console.log('生物识别是否可用:', available);
|
|
|
-
|
|
|
- // if (!available) {
|
|
|
- // alert('设备不支持或未设置生物识别');
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // const result = await BiometricAuth.authenticate({
|
|
|
- // reason: '请进行生物识别验证',
|
|
|
- // });
|
|
|
-
|
|
|
- // if (result.success) {
|
|
|
- // alert('验证成功');
|
|
|
- // // 执行支付等后续逻辑
|
|
|
- // } else {
|
|
|
- // alert('验证失败或取消');
|
|
|
- // }
|
|
|
-
|
|
|
await BiometricAuth.authenticate({
|
|
|
- reason: '请进行身份验证', // 验证提示
|
|
|
- cancelTitle: 'Cancel', // 取消按钮
|
|
|
- allowDeviceCredential: true, // 是否允许使用设备密码
|
|
|
- iosFallbackTitle: '使用密码',// iOS fallback
|
|
|
- androidTitle: '生物识别登录', // Android title
|
|
|
+ reason: '请进行身份验证',
|
|
|
+ cancelTitle: '取消',
|
|
|
+ allowDeviceCredential: true,
|
|
|
+ iosFallbackTitle: '使用密码',
|
|
|
+ androidTitle: '生物识别登录',
|
|
|
androidSubtitle: '使用生物识别认证登录',
|
|
|
androidConfirmationRequired: false,
|
|
|
- androidBiometryStrength: AndroidBiometryStrength.weak, // Android biometry strength
|
|
|
- })
|
|
|
+ androidBiometryStrength: AndroidBiometryStrength.weak,
|
|
|
+ });
|
|
|
+ return true;
|
|
|
} catch (error) {
|
|
|
console.error('生物识别异常', error);
|
|
|
- alert('验证出错:' + error);
|
|
|
+ return false;
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
+
|
|
|
+
|