EddyVerbruggen / nativescript-fingerprint-auth

:nail_care: 👱‍♂️ Forget passwords, use a fingerprint scanner or facial recognition!
MIT License
134 stars 33 forks source link

Cancel event #61

Closed patrikengborg closed 4 years ago

patrikengborg commented 5 years ago

After invoking the verifyFingerprint function and the user presses cancel - How do I catch that cancel event / press?

Thanks.

patrikengborg commented 5 years ago

@EddyVerbruggen any idea? Would really appreciate some help on this one. Thanks.

EddyVerbruggen commented 4 years ago

Can you start by mentioning which platform(s) and perhaps share a repo I can look at?

patrikengborg commented 4 years ago

Hi @EddyVerbruggen ,

Thanks for getting back, and sorry about inadequate info.

The platform is iOS, and instead of publishing the whole repo I will try to give you a simplified code sample below.

import { FingerprintAuth } from 'nativescript-fingerprint-auth'

const fingerprintAuth = new FingerprintAuth()

async function auth() {
  try {
    const result = await fingerprintAuth.verifyFingerprint()
    // Fingerprint auth succeeded
  } catch (error) {
    // Fingerprint auth failed
  }
}

auth()

My problem is that I can only detect if the fingerprint verification succeeds or fails. In my case, I need to perform a redirect if the user taps the cancel button. In that case the verifyFingerprint function neither succeeds or fails.

So is there a cancel event to listen for or any other way to know that the user tapped cancel?

I hope I was able to give you a better description now.

Thank you.

EddyVerbruggen commented 4 years ago

Hi, that's very clear indeed, thanks! I don't think it's possible for me to know whether that function failed or was cancelled, but perhaps if you use verifyFingerprintWithCustomFallback you may get the relevant details in the reject (or catch in your case) because of this line.. can you give that a shot?

patrikengborg commented 4 years ago

Yes!

{ code: -2, message: 'Canceled by user.' }

Brilliant, thank you so much!