Original blog, reproduced please indicate the source
Blog.csdn.net/hello_hwc
After iOS 8.0, Apple has opened an app that uses Touch ID to authenticate. But there are a few things to note:
- The app simply proxies the authentication process to the iOS system and does not get specific information about the fingerprint.
- Do not try to compare the fingerprint information with other databases, it is impossible for me to write this day.
Used by
Start validation
Validation failed
Supported devices
- IPhone 5s +
- IPad Air 2 +
- IPad Mini 3 +
How to use
Framework used by import
#import <LocalAuthentication/LocalAuthentication.h>
Initialize a Lacontext
LAContext * context = [[LAContext alloc] init];
Check whether the current device supports TouchID
NSError * error = nil; if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { ...}
Touch ID Authentication if supported
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"To login in" reply:^(BOOLNSError *error) { if (success) { //成功 }else{ //失败 }}];
Of these, there are several types of error that failed to return
- Laerrorauthenticationfailed-fingerprint authentication failed
- Laerrorusercancel-User cancels authentication (e.g. click Cancel)
- Laerroruserfallback-User Cancel (click input password)
- Laerrorsystemcancel-System Cancel
- Laerrorpasscodenotset-System does not have a password set
- Laerrortouchidnotavailable-Device does not support TouchID
- Laerrortouchidnotenrolled-touch ID not set (one fingerprint not)
IOS SDK app with Touch ID authentication