TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2016 |
Maintained by Vladimir Popko.
VPBiometricAuthenticationFacade is a high level wrapper for LocalAuthentication framework that provides ability to enable, disable and grant access to your application features by evaluating biometric policy (Touch ID).
Full description of project is available here (RUS)
#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
}];
Method calls failure block if biometric authentication isn't available on current device. Error code kVPBiometricsUnavailabilityErrorCode
.
[biometricFacade disableAuthenticationForFeature:@"My secure feature" withReason:@"Authentication reason" succesBlock:^{
// Authentication disabled
} failureBlock:^(NSError *error) {
// Failed to disable authentication
}];
"Reason" parameter is app-provided reason for requesting authentication. This string should be provided in the user’s current language and should be short and clear. It will be displayed in the sub-title of the authentication dialog.
Execution of this method leads to display system authentication dialog.
Method calls failure block in next cases:
1. If biometric authentication isn't available on current device. Error code kVPBiometricsUnavailabilityErrorCode
;
2. If user cancels authentication. Error code kLAErrorUserCancel
;
3. If user failed to pass authentication. Error code kLAErrorAuthenticationFailed
;
4. If user taps the fallback button (Enter Password). Error code kLAErrorUserFallback
;
5. If another application goes to foreground. Error code kLAErrorSystemCancel
.
[biometricFacade authenticateForAccessToFeature:@"My secure feature" withReason:@"Authentication reason" succesBlock:^{
// Access granted
} failureBlock:^(NSError *error) {
// Access denied
}];
Execution of this method leads to display system authentication dialog.
See previous method description to understand "reason" parameter and possible error codes in failureBlock.
VPBiometricAuthenticationFacade
for every attempt to pass authentication.It requires building with iOS SDK 8.0 and later. However it can be integrated to app with lower target version.
VPBiometricAuthenticationFacade is released under the MIT license. See LICENSE for details.