import{checkStatus}from'@tauri-apps/plugin-biometric';conststatus=awaitcheckStatus();if(status.isAvailable){console.log('Yes! Biometric Authentication is available');}else{console.log('No! Biometric Authentication is not available due to '+status.error);}
1
2
3
4
5
6
7
8
9
10
usetauri_plugin_biometric::BiometricExt;fncheck_biometric(app_handle: tauri::AppHandle){letstatus=app_handle.biometric().status().unwrap();ifstatus.is_available{println!("Yes! Biometric Authentication is available");}else{println!("No! Biometric Authentication is not available due to: {}",status.error.unwrap());}}
import{authenticate}from'@tauri-apps/plugin-biometric';constoptions={// 若希望用户可以使用手机密码认证,请设为 true
allowDeviceCredential:false,cancelTitle:"Feature won't work if Canceled",// 仅 iOS 的特性
fallbackTitle:'Sorry, authentication failed',// 仅 Android 的特性
title:'Tauri feature',subtitle:'Authenticate to access the locked Tauri function',confirmationRequired:true,};try{awaitauthenticate('This feature is locked',options);console.log('Hooray! Successfully Authenticated! We can now perform the locked Tauri function!');}catch(err){console.log('Oh no! Authentication failed because '+err.message);}
{"$schema":"../gen/schemas/desktop-schema.json","identifier":"main-capability","description":"Capability for the main window","windows":["main"],"permissions":["biometric:default"]}