我正在开发一个需要Touch ID认证的应用程序,那么有什么方法可以在模拟器中使用Touch ID (指纹扫描仪)吗?
另外,请共享一些使用LocalAuthentication框架的示例代码。
发布于 2014-08-23 08:37:46
从Xcode 7开始,模拟器支持'touchID‘。下面的答案包含更多的信息。
在最新的测试版(6)中,没有办法在模拟器上模拟指纹扫描。老实说,我怀疑这甚至会包括在以后的贝塔。
您需要在设备上进行测试。
要立即使用身份验证框架,您需要:* XCode 6* iPhone 5和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/找到更多信息
发布于 2015-07-04 05:02:33
XCODE 7 beta支持测试iPhone Simulator.You中的Touch ID身份验证,可以在您的测试中尝试这一点。
屏幕截图1

屏幕截图2

发布于 2021-03-02 19:07:40
对于xCode 12
特性-> Touch ID

https://stackoverflow.com/questions/25459059
复制相似问题