Is there any way to use apple's Touch ID (fingerprint scanner) on iOS Simulator?

32,635

Solution 1

As of Xcode 7 the Simulator supports 'touchID'. Answer below contains further info.

As of the latest beta (6) there is no way to simulate a fingerprint scan on the simulator. To be honest I doubt this will be included even in later betas.

You will need to test on device.

To use the Authentication framework right now you need: * XCode 6 * iPhone 5s with iOS 8

The steps you need to perform are:

Find out whether the device supports fingerprint validation and whether a fingerprint is enrolled:

@import LocalAuthentication;

// Get the local authentication context:
LAContext *context = [[LAContext alloc] init];

// Test if fingerprint authentication is available on the device and a fingerprint has been enrolled.
if ([context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil])
{
    NSLog(@"Fingerprint authentication available.");
}

Validate a fingerprint only:

[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Authenticate for server login" reply:^(BOOL success, NSError *authenticationError){
    if (success) {
        NSLog(@"Fingerprint validated.");
    }
    else {
        NSLog(@"Fingerprint validation failed: %@.", authenticationError.localizedDescription);
    }
}];

Validate a fingerprint or the device’s passcode depending on the user’s choice: This is a little beyond the scope of a question here, please find more information at: https://www.secsign.com/fingerprint-validation-as-an-alternative-to-passcodes/

Solution 2

XCODE 7 beta supports testing the Touch ID Authentication in iPhone Simulator.You can try this for your testing.

[Screenshot 1]

[Screenshot 1]

[Screenshot 2]

[Screenshot 2]

Solution 3

For xCode 12

Features -> Touch ID

enter image description here

Share:
32,635

Related videos on Youtube

Ashish
Author by

Ashish

Updated on July 09, 2022

Comments

  • Ashish
    Ashish almost 2 years

    I am working on an app which would require Touch ID Authentication, so is there any way i can use Touch ID (fingerprint scanner) in the simulator ?

    Also, please do share some kind of example code for using LocalAuthentication framework.

    • arekolek
      arekolek almost 7 years
      If you ever read this, accept the other answer please.
  • user1872384
    user1872384 over 9 years
    Ouch...Wanted to test touch id with the apple watch,i have an iPhone6 but not a watch. Really, hope that we can just use the simulator to test touch id.
  • es3735746
    es3735746 over 8 years
    how can we trigger this action with selenium?
  • Josh Gafni
    Josh Gafni about 8 years
    Is it possible to trigger this within the setUp of a UITest's XCTestCase?
  • Tri Nguyen
    Tri Nguyen almost 8 years
    Even after I enabled "Touch ID Enrolled", I am still getting "Pay with Passcode" prompt instead of the fingerprint. Does anyone know why that might be?
  • thinklinux
    thinklinux about 6 years
    There is support now See @karthik answer below! This answer should be updated :))