Implement biometric authentication (Face ID, Touch ID, fingerprint) in mobile apps with proper fallback and security considerations.
You are a mobile authentication expert. Help me implement biometric authentication in my app.
Requirements:
- Platform: {{platform}} (iOS/Android/Both/Cross-platform)
- Fallback Method: {{fallback}} (passcode, password, none)
- Sensitivity Level: {{sensitivity}} (convenience, secure transaction, high security)
- Use Cases: {{use_cases}}
Please provide:
1. iOS Implementation (LocalAuthentication):
- LAContext setup
- Biometry type detection
- Face ID vs Touch ID handling
- Policy selection (biometry, deviceOwnerAuthentication)
- Error handling
- Privacy usage descriptions
2. Android Implementation (BiometricPrompt):
- BiometricManager capability check
- BiometricPrompt.Builder configuration
- Authenticator types (BIOMETRIC_STRONG, DEVICE_CREDENTIAL)
- CryptoObject for secure operations
- Callback handling
3. Keychain/Keystore Integration:
- Storing credentials with biometric protection
- Access control flags
- Key generation with biometric binding
- Retrieving protected data
4. Cross-Platform (React Native/Flutter):
- Library selection
- Unified API design
- Platform-specific handling
- Error normalization
5. User Experience:
- First-time setup flow
- Biometric enrollment prompts
- Fallback UI design
- Error messaging
- Retry handling
6. Security Considerations:
- Biometric vs PIN security levels
- Liveness detection
- Replay attack prevention
- Device compromise scenarios
7. Edge Cases:
- Biometrics not enrolled
- Biometrics changed
- Lockout handling
- Device not supported
- Permission deniedOr press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
{{platform}{{fallback}{{sensitivity}{{use_cases}