Checks if biometric sensors are available on the device. This method can be used to determine whether or not to show biometric registration options.
Get sensor
Method parameters
allowDeviceCredentials string
import { useStytch } from '@stytch/react-native';
import React, { useCallback, useEffect, useState } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
export const Register = () => {
const stytch = useStytch();
const [isSensorAvailable, setIsSensorAvailable] = useState(false);
useEffect(() => {
const checkSensorAvailability = async () => {
if (stytch) {
try {
await stytch.biometrics.getSensor();
setIsSensorAvailable(true);
} catch {
setIsSensorAvailable(false);
}
} else {
setIsSensorAvailable(false);
}
};
checkSensorAvailability();
}, [stytch]);
const registerBiometrics = useCallback(() => {
stytch.biometrics.register({
prompt: 'Register with Biometrics',
});
}, [stytch]);
return isSensorAvailable ? (
<View>
<TouchableOpacity onPress={registerBiometrics}>
<Text>Register with Biometrics</Text>
</TouchableOpacity>
</View>
) : null;
};