EddyVerbruggen / nativescript-fingerprint-auth

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

IOS code access, no error code (always undefined) #48

Open Robernator opened 5 years ago

Robernator commented 5 years ago

On an IOS device when canceling the access code, you do not receive an error code. With Android you get an error code 60 with IOS, the error is always undefined. I cannot make a distinguish whether or not the access code is enabled on the device.

bradmartin commented 5 years ago

It's possible on iOS the user can end up locking access to the security within the app.

I use the following code to check

 if (isIOS) {
              // check if Biometry is locked out.
              const laContext = LAContext.new();
              laContext.evaluatePolicyLocalizedReasonReply(
                LAPolicy.DeviceOwnerAuthentication,
                'test',
                (ok: boolean, error: NSError) => {
                  if (!ok) {
                    console.log(error.code, error.localizedDescription);
                    if (error.code === LAError.BiometryLockout) {
                     console.log(
                        `Biometry is locked out. User must enter passcode to enable Biometry.`,
                      );
                    } else if (error.code === LAError.UserCancel) {
                      console.log(`The user tapped the cancel button in the authentication dialog.`);
                      reject();
                    }
                    resolve();
                  } else {
                    resolve(ok);
                  }
                },
              );
            } 

I end up checking that if the available call does NOT return result.any in the promise.