Open saikats5 opened 3 years ago
Expo and native modules basically doesn't work, you will need to contact Expo support. There is a chance you might get it to work if you use the bare workflow, but as with all things Expo, if there are problems, contact Expo support.
If you can reproduce the problem with the example app provided, then the module has a problem, but this is probably Expo related
I am trying to implement it on an expo project and is trying a basic code(added below) to test it on my physical iPhone 8 device, but it is not supporting the biometric, throwing this error -> isSensorAvailable error => [TypeError: null is not an object (evaluating 'ReactNativeFingerprintScanner.isSensorAvailable')]
Code
import React, {Component} from 'react'; import {Text, SafeAreaView, StyleSheet, TouchableOpacity} from 'react-native'; import FingerprintScanner from 'react-native-fingerprint-scanner'; export default class App extends Component { constructor() { super();
} componentDidMount() { FingerprintScanner.isSensorAvailable() .then((biometryType) => { this.setState({biometryType}); }) .catch((error) => console.log('isSensorAvailable error => ', error)); }
getMessage=()=>{ const {biometryType}=this.state; if(biometryType=='Face ID') { return 'Scan your Face on the device to continue' } else { return 'Scan your Fingerprint on the device scanner to continue' } }
showAuthenticationDialog = () => { const {biometryType}=this.state; if(biometryType!==null && biometryType!==undefined ) { FingerprintScanner.authenticate({ description: this.getMessage() }) .then(() => { //you can write your logic here to what will happen on successful authentication }) .catch((error) => { console.log('Authentication error is => ', error); }); } else { console.log('biometric authentication is not available'); } };
render() { const {biometryType}=this.state; return (
} }
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, buttonStyle: { width: '70%', backgroundColor: '#000', borderRadius: 25, padding: 10, justifyContent: 'center', alignItems: 'center', }, buttonText: {color: '#fff', fontSize: 17, fontWeight: 'bold'}, biometryText: { color: '#000', fontSize: 17, fontWeight: 'bold', marginTop: 30, }, });
I don't have any other device right now and also I don't have the USB to connect it to my mac, that's why I am using expo project to test it, then I would be implementing it to a react-native-cli project