Provides methods to manage local authentication on iOS devices, including:
- Checking biometric availability (Face ID, Touch ID, or Optic ID)
- Setting up biometric authentication with a localized reason
- Authenticating users using biometrics
- Retrieving the available biometric type
- Clear and concise API for easy integration
- Error handling for common authentication issues
- Logging for debugging and troubleshooting
- Support for testing with a mock LAContext
- Compatibility with iOS 10.0 and later
Add the package to your Package.swift file:
dependencies: [
.package(url: "https://github.com/LLCFreedom-Space/fs-local-authentication-provider", from: "1.0.0")
]
Import the package in your Swift files:
import LocalAuthenticationProvider
Import the library:
import LocalAuthenticationProvider
Create an instance of LocalAuthenticationProvider
:
let provider = LocalAuthenticationProvider()
Use the provided methods to perform authentication tasks:
// Check if biometric authentication is available
if try await provider.checkBiometricAvailable(with: .biometrics) {
// Set up biometric authentication
if try await provider.setBiometricAuthentication(localizedReason: "Authenticate to access your data") {
// Authenticate the user
if try await provider.authenticate(localizedReason: "Confirm your identity") {
// Authentication successful!
} else {
// Authentication failed
}
} else {
// Biometric authentication could not be set up
}
} else {
// Biometric authentication is not available
}
We welcome contributions to this project! Please feel free to open issues or pull requests to help improve the package.
LLC Freedom Space – @LLCFreedomSpace – support@freedomspace.company
Distributed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3. See LICENSE.md for more information.