Face ID / Touch ID Integration for iOS Authentication
This repository contains the code and project examples for integrating Face ID and Touch ID in your iOS applications. The project is based on the concepts outlined in the Medium article titled “Integrating Face ID or Touch ID for User Authentication in Your App.” The implementation leverages the LocalAuthentication framework to improve user authentication experiences and ensure secure access to apps.
Features
• Face ID and Touch ID Integration: Allows users to authenticate securely using biometrics.
• Custom Authentication Context: Easily configure authentication prompts for both Face ID and Touch ID.
• Error Handling and Fallback: Detect if the device supports biometric authentication, handle errors, and provide fallbacks for non-supported devices.
• UI Customization: Adapt the UI depending on the availability of Face ID or Touch ID on the user’s device.
Usage
1. Adding Face ID/Touch ID Support: Ensure your app’s Info.plist file contains the appropriate usage descriptions for Face ID (NSFaceIDUsageDescription).
2. Creating Authentication Context:
• Create and configure an LAContext instance to manage biometric authentication in the app.
• Customize the cancel button title for user-friendly interactions.
3. Testing Biometric Availability:
• Use canEvaluatePolicy(_:error:) to check if the device supports biometric authentication.
4. Executing Authentication:
• Once ready, prompt the user for authentication using evaluatePolicy(_:localizedReason:reply:).
5. UI Adjustments:
• Handle differences between Face ID and Touch ID in the user interface by adapting to the specific technology available on the device.
Requirements
• iOS 11.0+
• Xcode 12.0+
• Swift 5.0+
Contributing
Feel free to submit pull requests to improve the examples or suggest new features!