Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TouchID forward to system passcode authentication

I want to use TouchID authenticate my own app.

1.I want user can click 'Enter passcode' to invoke system build-in passcode screen to authenticate,if success then enter my own app.
But I don't how know to make it forward to passcode authenticate view like the following screen in 'case LAErrorUserFallback' enter image description here

Here is my code :

LAContext *context = [[LAContext alloc] init];
__block  NSString *msg;
__block  BOOL bAuth;
// show the authentication UI with our reason string
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"Unlock APP With FingerPrint", nil) reply:
^(BOOL success, NSError *authenticationError) {

   if (success) {
      bAuth = YES;
      msg =[NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_SUCCESS", nil)];
      dispatch_async(dispatch_get_main_queue(), ^{
         [[MYAppDelegate theDelegate] initializeAppAfterKeyVaultUnlocked];
      });
      NSLog(@"%@",msg);
   } else {
      bAuth = NO;
      switch (authenticationError.code) {
         case LAErrorAuthenticationFailed:
            msg = [NSString stringWithFormat:NSLocalizedString(@"Authentication Failed", nil)];
            // ...
            break;

         case LAErrorUserCancel:
            msg = [NSString stringWithFormat:NSLocalizedString(@"User pressed Cancel button", nil)];
            dispatch_async(dispatch_get_main_queue(), ^{
               [[MYAppDelegate theDelegate] exitAndLock];
            });

            break;

         case LAErrorUserFallback:
            msg = [NSString stringWithFormat:NSLocalizedString(@"User pressed \"Enter Password\"", nil)];
            //Here I want to fallback to iOS build-in passcode authenticate view, and get the auth result.
            break;

         default:
            msg = [NSString stringWithFormat:NSLocalizedString(@"Touch ID is not configured", nil)];
            // ...
            break;
      }
      NSLog(@"%@",authenticationError.localizedDescription);

   }


}];
like image 810
eric Avatar asked Aug 20 '14 05:08

eric


People also ask

Can I use passcode instead of Face ID on iPhone 13?

Users can use their passcode or password anytime instead of Face ID or Touch ID, but there are situations where biometrics aren't permitted. The following security-sensitive operations always require entry of a passcode or password: Updating the software. Erasing the device.

Why does Mac need password instead of Touch ID?

For security reasons, Mac devices with Touch ID are designed to first ask for passwords after every login. It doesn't matter if you've just set up your Touch ID or not; as long as you're just logging in afresh on your Mac, you'll be required to enter your password for safety purposes.

What is Touch ID authentication?

Touch ID is an electronic fingerprint recognition feature designed and released by Apple Inc. that allows users to unlock devices, make purchases in the various Apple digital media stores (iTunes Store, App Store, and Apple Books Store), and authenticate Apple Pay online or in apps.

What is the difference between Face ID and Touch ID?

As we said Face ID requires you to have open eyes, while Touch ID only requires a fingerprint. There are good and bad things about this. In an accident it would be easy to unlock your iPhone and contact a family member.


1 Answers

Now in iOS 9 it is pretty simple actually - you just have to use LAPolicyDeviceOwnerAuthentication instead of LAPolicyDeviceOwnerAuthenticationWithBiometrics

So in your code you just replace this:

[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"Unlock APP With FingerPrint", nil) reply:
^(BOOL success, NSError *authenticationError) {

With this:

[context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:NSLocalizedString(@"Unlock APP With FingerPrint", nil) reply:
^(BOOL success, NSError *authenticationError) {

Thus, when user fails to authenticate with fingerprint, there'd be "enter passcode" option which would invoke system passcode input screen.

like image 179
Dannie P Avatar answered Sep 20 '22 15:09

Dannie P