VPBiometricAuthenticationFacade
High level wrapper for LocalAuthentication framework
Install / Use
/learn @Visput/VPBiometricAuthenticationFacadeREADME
VPBiometricAuthenticationFacade v1.0.4
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)
Installation
CocoaPods
Add to your Podfile pod "BiometricAuthenticationFacade".
Drag&Drop
- Drag and drop BiometricAuthenticationFacade.xcodeproj to your project;
- Add BiometricAuthenticationFacade to Build Phases -> Target Dependencies;
- Add BiometricAuthenticationFacade.framework to Build Phases -> Link Binary With Libraries;
- Add LocalAuthentication standard framework to your project.
Usage
Import framework header
#import <BiometricAuthenticationFacade/VPBiometricAuthenticationFacade.h>
Create object instance
VPBiometricAuthenticationFacade *biometricFacade = [[VPBiometricAuthenticationFacade alloc] init];
Check if biometric authentication is available on current device
if (biometricFacade.isAuthenticationAvailable) {
// Authentication available
}
Check if authentication for specific feature is enabled
if ([biometricFacade isAuthenticationEnabledForFeature:@"My secure feature"]) {
// Authentication enabled
}
Enable authentication for specific feature
[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.
Disable authentication for specific feature
[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:
- If biometric authentication isn't available on current device. Error code
kVPBiometricsUnavailabilityErrorCode; - If user cancels authentication. Error code
kLAErrorUserCancel; - If user failed to pass authentication. Error code
kLAErrorAuthenticationFailed; - If user taps the fallback button (Enter Password). Error code
kLAErrorUserFallback; - If another application goes to foreground. Error code
kLAErrorSystemCancel.
Authenticate for access to specific feature
[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.
Notes
- Blocks in all methods are called on the main thread;
- Internal implementation of LocalAuthentication framework uses cache time in approximately 15 minutes. It means that if you successfully pass biometric authentication and then will try repeat the process in short period of time then system won't show authentication dialog, it will grant access immediately. If you need avoid such behaviour with cache time you have to use new instance of
VPBiometricAuthenticationFacadefor every attempt to pass authentication.
System Requirements
It requires building with iOS SDK 8.0 and later. However it can be integrated to app with lower target version.
License
VPBiometricAuthenticationFacade is released under the MIT license. See LICENSE for details.
Related Skills
node-connect
341.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.4kCommit, push, and open a PR
