测试经测试 | ✗ |
语言语言 | Obj-CObjective C |
许可 | MIT |
发布最后发布 | 2016年10月 |
由Vladimir Popko维护。
VPBiometricAuthenticationFacade是一个针对LocalAuthentication框架的高级包装器,它通过评估生物识别策略(触摸ID)来提供启用、禁用并授予应用功能访问权限的能力。
项目的完整描述在这里(俄语)可供参考http://habrahabr.ru/post/235699/
#import <BiometricAuthenticationFacade/VPBiometricAuthenticationFacade.h>
VPBiometricAuthenticationFacade *biometricFacade = [[VPBiometricAuthenticationFacade alloc] init];
if (biometricFacade.isAuthenticationAvailable) {
// Authentication available
}
if ([biometricFacade isAuthenticationEnabledForFeature:@"My secure feature"]) {
// Authentication enabled
}
[biometricFacade enableAuthenticationForFeature:@"My secure feature" succesBlock:^{
// Authentication enabled
} failureBlock:^(NSError *error) {
// Failed to enable authentication
}];
如果当前设备不支持生物识别认证,则方法调用将失败。错误代码 kVPBiometricsUnavailabilityErrorCode
。
[biometricFacade disableAuthenticationForFeature:@"My secure feature" withReason:@"Authentication reason" succesBlock:^{
// Authentication disabled
} failureBlock:^(NSError *error) {
// Failed to disable authentication
}];
"原因"参数是应用提供的请求认证的原因。此字符串应使用用户的当前语言提供,应简短、清晰。它将显示在认证对话框的副标题中。
执行此方法会导致显示系统认证对话框。
以下情况下方法调用将失败:
1. 如果当前设备上不可用生物识别认证。错误代码:kVPBiometricsUnavailabilityErrorCode
;
2. 如果用户取消认证。错误代码:kLAErrorUserCancel
;
3. 如果用户未能通过认证。错误代码:kLAErrorAuthenticationFailed
;
4. 如果用户点击了备用按钮(输入密码)。错误代码:kLAErrorUserFallback
;
5. 如果其他应用程序进入前台。错误代码:kLAErrorSystemCancel
。
[biometricFacade authenticateForAccessToFeature:@"My secure feature" withReason:@"Authentication reason" succesBlock:^{
// Access granted
} failureBlock:^(NSError *error) {
// Access denied
}];
执行此方法会导致显示系统认证对话框。
参见之前的方法描述,了解“reason”参数和在failureBlock中可能的错误代码。
VPBiometricAuthenticationFacade
实例。它需要使用iOS SDK 8.0和更高版本构建。然而,它可以与低于目标版本的应用程序集成。
VPBiometricAuthenticationFacade是在MIT许可证下发布的。有关详细信息,请参阅LICENSE。