有没有办法在iOS模拟器上使用苹果的Touch ID(指纹扫描仪)? [英] Is there any way to use apple's Touch ID (fingerprint scanner) on iOS Simulator?

查看:1134
本文介绍了有没有办法在iOS模拟器上使用苹果的Touch ID(指纹扫描仪)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款需要Touch ID身份验证的应用,所以我有什么方法可以在模拟器中使用Touch ID(指纹扫描仪)吗?

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 ?

,请分享使用LocalAuthentication框架的某种示例代码。

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

推荐答案

从Xcode 7开始,模拟器支持'touchID'。下面的答案包含更多信息。



截至最新测试版(6),无法在模拟器上模拟指纹扫描。说实话,我怀疑即使在以后的测试版中也会包括这些。

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.

要立即使用身份验证框架,您需要:
* XCode 6
*带iOS 8的iPhone 5s

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

您需要执行的步骤是:

了解该设备是否支持指纹验证以及是否已注册指纹:

@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.");
}

仅验证指纹:

[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);
    }
}];

根据用户的选择验证指纹或设备的密码:
这有点超出了问题的范围,请在以下网址找到更多信息: https://www.secsign.com/fingerprint-validation-as-an-alternative-to-passcodes/

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/

这篇关于有没有办法在iOS模拟器上使用苹果的Touch ID(指纹扫描仪)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆