typedefNS_ENUM(NSInteger,LAError){/// Authentication was not successful, because user failed to provide valid credentials.LAErrorAuthenticationFailed=kLAErrorAuthenticationFailed,/// Authentication was canceled by user (e.g. tapped Cancel button).LAErrorUserCancel=kLAErrorUserCancel,/// Authentication was canceled, because the user tapped the fallback button (Enter Password).LAErrorUserFallback=kLAErrorUserFallback,/// Authentication was canceled by system (e.g. another application went to foreground).LAErrorSystemCancel=kLAErrorSystemCancel,/// Authentication could not start, because passcode is not set on the device.LAErrorPasscodeNotSet=kLAErrorPasscodeNotSet,/// Authentication could not start, because Touch ID is not available on the device.LAErrorTouchIDNotAvailable=kLAErrorTouchIDNotAvailable,/// Authentication could not start, because Touch ID has no enrolled fingers.LAErrorTouchIDNotEnrolled=kLAErrorTouchIDNotEnrolled,}NS_ENUM_AVAILABLE(10_10,8_0);
Touch ID API 简单封装Demo
TouchIdUtil.h
123456789101112131415161718192021222324
typedefNS_ENUM(NSInteger,TouchIdEvaluateResult){kTouchIdEvaluateResultSuccess,// 验证成功kTouchIdEvaluateResultFailed,// 验证失败kTouchIdEvaluateResultCancel,// 点击取消按钮kTouchIdEvaluateResultFallback,// 点击回退按钮kTouchIdEvaluateResultOther// 未知结果};typedefvoid(^TouchIdEvaluateCallback)(TouchIdEvaluateResultresult);@interfaceTouchIdUtil : NSObject+(instancetype)sharedInstance;// Touch Id 是否开启或设置-(BOOL)canEvaluatePolicy;// Touch Id 验证 callback回调已经抛到了主线程-(void)evaluatePolicy:(NSString*)localizedReasionfallbackTitle:(NSString*)titlecallback:(TouchIdEvaluateCallback)cb;@end