Use the authenticate method to trigger the biometric prompt. It accepts an options object and returns a Promise.
iOS Usage:
FingerprintScanner.authenticate({ description: 'Scan your fingerprint...' })
.then(() => { /* success */ })
.catch((error) => { /* error */ });
Android Usage (Current API >= v23):
FingerprintScanner.authenticate({ title: 'Log in with Biometrics' })
.then(() => { /* success */ });
Android Usage (Legacy API < v23):
For older devices, you can use the onAttempt callback:
FingerprintScanner.authenticate({ onAttempt: (error) => { /* handle attempt */ } })
.then(() => { /* success */ })
.catch((error) => { /* error */ });
Important: Always call FingerprintScanner.release() when the component unmounts to free up resources.
import FingerprintScanner from 'react-native-fingerprint-scanner';
FingerprintScanner.authenticate({ title: 'Log in with Biometrics' })
.then(() => {
console.log('Authenticated successfully');
})
.catch((error) => {
console.log(error.message);
});