To move from the Touch ID dialog to the passcode entry screen, as in au WALLET:

Asked 2 years ago, Updated 2 years ago, 54 views

There is an authentication screen using Touch ID in an app called au WALLET on iOS.
You can also unlock it by entering the passcode directly there.

"Is the ""passcode direct input view"" from the Touch ID customized?"
Is it the iPhone system lock screen?

I looked it up online, but there seems to be no way to call the system lock screen.

===============================
We share the source implemented for testing.
browsing:
[Reference 1] https://developer.apple.com/library/ios/samplecode/KeychainTouchID/Introduction/Intro.html
[Reference 2] https://www.secsign.com/fingerprint-validation-as-an-alternative-to-passcodes/

// show the authentication UI with your reason string
LAContext*context=[[LAContext alloc] init];
__block NSSstring* msg;

context validatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"UNLOCK_ACCESS_TO_LOCKED_FATURE",nil) reply:
 ^(BOOL success, NSError* authenticationError) {
     if(success){
         msg = [NSSstring stringWithFormat: NSLocalizedString(@"EVALUATE_POLICY_SUCCESS", nil)];
     } else{
         msg = [NSString stringWithFormat: NSLocalizedString(@"EVALUATE_POLICY_WITH_ERROR", nil), authenticationError.localizedDescription];

         if(authenticationError.code==LAErrorUserFallback){

             // The identifier and service name together will unique identify the keychain entry.
             NSSstring* keychainItemIdentifier=@"fingerprintKeychainEntry";
             NSSstring*keychainItemServiceName=@"com.secsign.secsign";

             // Determine a string which the device will display in the fingerprint view exhibiting the reason for the fingerprint scan.
             NSSstring*secUseOperationPrompt=@"Authenticate for server login";

             // The keychain operation shall be performed by the global queue. Otherwise it right just nothing Happen.
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUUEUE_PRIORITY_DEFAULT, 0),^(void){

                 // Create the keychain query attributes using the values from the first part of the code.
                 NSMutableDictionary*query=[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                                (__bridge id)(kSecClassGenericPassword), kSecClass,
                                                keychainItemIdentifier, kSecAttrAccount,
                                                keychainItemServiceName, kSecAttrService,
                                                secUseOperationPrompt, kSecUseOperationPrompt,
                                                nil];

                 // Start the query and the fingerprint scan and/or device passcode validation
                 CFTypeRefresult=nil;
                 OSSStatus userPresenceStatus=SecItemCopyMatching(__bridge CFDictionaryRef)query, & result);

                 // Ignore the found content of the key chain entry (the dummy password) and only validate the return code.
                 if(noErr==userPresenceStatus)
                 {
                     NSLog(@"Fingerprint or device passcode validated.");
                 }
                 else
                 {
                     NSLog(@"Fingerprint or device passcode could not be validated.Status%d.,(int)userPresenceStatus);
                 }

                 // To process the result at this point there would be a call to delete method which 
                 // would do things work like GUI operations in the main queue. That means it would start
                 // with something like:
                 //   dispatch_async(dispatch_get_main_queue(),^{
             });
         }
     }
     [self printResult:self.textView message:msg];
 }];

ios objective-c

2022-09-30 19:04

1 Answers

Instead of displaying the lock screen, use the LocalAuthentication Framework as shown below.

This is an example of a UIButton implementation on the StoryBoard, eliminating unnecessary parts.

@importLocalAuthentication;
@implementation ViewController

- (IBAction) buttonTouchUpInside: (id) sender {
  LAContext*context= [LAContext new];
  NSError* error;
  if ([context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error: & error]) {
    context validatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics
        localizedReason:@ "Fingerprint Authentication"
              reply:^(BOOL success, NSError* error) {
                if(success){
                  NSLog(@"Success");
                } else{
                  NSLog(@"An Auth Error Occurred:%@", error);
                }
              }];
  } else{
    NSLog(@"An Error Occurred:%@", error);
  }
}

The localizedReason string appears on the fingerprint authentication screen.

Also, the simulator cannot verify operation, so please transfer it to the actual machine and try it.


2022-09-30 19:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.