@@ -66,6 +66,7 @@ Install the biometric plugin to get started.
6666 />
6767 </Steps >
6868 </TabItem >
69+
6970</Tabs >
7071
7172## Usage
@@ -77,6 +78,22 @@ This plugin enables you to verify the availability of Biometric Authentication o
7778You can check the status of Biometric Authentication, including its availability and the types of biometric authentication methods supported.
7879
7980<Tabs >
81+ <TabItem label = " JavaScript" >
82+
83+ ``` javascript
84+ import { checkStatus } from ' @tauri-apps/plugin-biometric' ;
85+
86+ const status = await checkStatus ();
87+ if (status .isAvailable ) {
88+ console .log (' Yes! Biometric Authentication is available' );
89+ } else {
90+ console .log (
91+ ' No! Biometric Authentication is not available due to ' + status .error
92+ );
93+ }
94+ ```
95+
96+ </TabItem >
8097<TabItem label = " Rust" >
8198
8299``` rust
@@ -92,34 +109,52 @@ fn check_biometric(app_handle: tauri::AppHandle){
92109```
93110
94111</TabItem >
112+ </Tabs >
113+
114+ ### Authenticate
115+
116+ To prompt the user for Biometric Authentication, utilize the ` authenticate() ` method.
117+
118+ <Tabs >
95119
96120<TabItem label = " JavaScript" >
97121
98- ``` javascript
99- import { checkStatus } from ' @tauri-apps/plugin-biometric' ;
122+ ``` javascript ins={18}
123+ import { authenticate } from ' @tauri-apps/plugin-biometric' ;
100124
101- const status = await checkStatus ();
102- if (status .isAvailable ){
103- console .log (" Yes! Biometric Authentication is available" );
104- } else {
105- console .log (" No! Biometric Authentication is not available due to " + status .error );
125+ const options = {
126+ // Set True if you want the user to be able to authenticate using phone password
127+ allowDeviceCredential: false ,
128+ cancelTitle: " Feature won't work if Canceled" ,
129+
130+ // iOS only feature
131+ fallbackTitle: ' Sorry, authentication failed' ,
132+
133+ // Android only features
134+ title: ' Tauri feature' ,
135+ subtitle: ' Authenticate to access the locked Tauri function' ,
136+ confirmationRequired: true ,
137+ };
138+
139+ try {
140+ await authenticate (' This feature is locked' , options);
141+ console .log (
142+ ' Hooray! Successfully Authenticated! We can now perform the locked Tauri function!'
143+ );
144+ } catch (err) {
145+ console .log (' Oh no! Authentication failed because ' + err .message );
106146}
107147```
108- </TabItem >
109- </Tabs >
110148
111- ### Authenticate
112-
113- To prompt the user for Biometric Authentication, utilize the ` authenticate() ` method.
149+ </TabItem >
114150
115- <Tabs >
116151<TabItem label = " Rust" >
117152
118153``` rust ins={21}
119154use tauri_plugin_biometric :: {BiometricExt , AuthOptions };
120155
121156fn bio_auth (app_handle : tauri :: AppHandle ) {
122-
157+
123158 let options = AuthOptions {
124159 // Set True if you want the user to be able to authenticate using phone password
125160 allow_device_credential : false ,
@@ -135,7 +170,7 @@ fn bio_auth(app_handle: tauri::AppHandle) {
135170 };
136171
137172 // If the authentication was succesfull, the function returns Result::Ok()
138- // And Result::Error() otherwise
173+ // And Result::Error() otherwise
139174 match app_handle . biometric (). authenticate (" This feature is locked" . to_string (), options ){
140175 Ok (_ ) => {
141176 println! (" Hooray! Successfully Authenticated! We can now perform the locked Tauri function!" );
@@ -146,34 +181,6 @@ fn bio_auth(app_handle: tauri::AppHandle) {
146181 }
147182}
148183```
149- </TabItem >
150-
151- <TabItem label = " JavaScript" >
152-
153- ``` javascript ins={18}
154- import { authenticate } from ' @tauri-apps/plugin-biometric' ;
155-
156- const options = {
157- // Set True if you want the user to be able to authenticate using phone password
158- allowDeviceCredential: false ,
159- cancelTitle: " Feature won't work if Canceled" ,
160-
161- // iOS only feature
162- fallbackTitle: " Sorry, authentication failed" ,
163-
164- // Android only features
165- title: " Tauri feature" ,
166- subtitle: " Authenticate to access the locked Tauri function" ,
167- confirmationRequired: true ,
168- };
169-
170- try {
171- await authenticate (" This feature is locked" , options);
172- console .log (" Hooray! Successfully Authenticated! We can now perform the locked Tauri function!" );
173- } catch (err) {
174- console .log (" Oh no! Authentication failed because " + err .message );
175- }
176- ```
177184
178185</TabItem >
179186</Tabs >
0 commit comments