stringreact-nativepromisefingerprinttouch-id

How to return a Boolean or just a promise that notifies when authentication succeeded?


I have implemented the code for Fingerprint authentication in React Native using react-native-fingerprint-scanner and its working fine. My concern might sound quite stupid but I am actually stuck on this when authentication succeeds I have no idea how to check that so that I can trigger a setState there. This code is just returning a string:

FingerprintScanner
        .authenticate((description, onAttempt) => {
            if (description) {
                this.setState({ Authenticated: true })
            }
            //description: 'Log in with Biometrics'
        })
        .then(() => {
            this.props.onAuthenticate();
        })

Note: the execution never reacher .then() callback otherwise I would have just set the state there. No idea why it does that!


Solution

  • Before calling the Authenticate or afterwards, I need to call this method to release the cache:

    FingerprintScanner.release();
    

    This way the user can Cancel and retry anytime.