mil*_*ari 3 iphone ios touch-id
有没有办法检查我的应用程序启用TouchID,
如何检查我的应用程序是否启用了TouchID,
例如 :
DropBox具有启用图形打印传感器功能的功能.现在有什么方法可以检查我的应用程序是否显示基于touchid启用的TouchID屏幕.
你不想检查iOS版本,当然,它可能有效,但这是一个不好的做法.请检查功能.查看LAContext是否可用.
if ([LAContext class]) {
// touch ID is available for the device
// call canEvaluatePolicy:error to see if the user has set a fingerprint.
}
Run Code Online (Sandbox Code Playgroud)
根据你使用Objective-C
首先,添加方法来检查iOS版本
TouchID 需要iOS8 +才能工作
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
Run Code Online (Sandbox Code Playgroud)
然后,LAContext canEvaluatePolicy:error:用来评估是否TouchID存在
预检验证策略以查看验证是否可能成功
- (BOOL)isTouchIDAvailable {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
return [[[LAContext alloc] init] canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4944 次 |
| 最近记录: |