Unfortunately, the Android BiometricPrompt API (and the older android.hardware.biometrics API) does not expose any fields or methods that provide a consistent, unique user ID for a biometric signature. This is by design to protect user privacy and ensure compliance with global data protection standards.
However, you can achieve your goal using the following approaches:
- Associate Biometrics with an App-Specific ID
When a user enrolls in your app, generate a unique ID (e.g., UUID) and store it securely in your backend along with the user profile.
Upon successful biometric authentication, associate the authenticated session with this unique ID on the server side.
- Use a Secure Token
Instead of relying on the biometric data itself, use the biometric prompt to authenticate the user and issue a secure token or session ID. This token can be associated with a unique user ID in your database.
- Biometric-Specific Notes
The Android BiometricPrompt does not give direct access to raw biometric data or any unique identifiers derived from it. It simply confirms the authentication status (pass/fail). You will need to manage user associations securely in your backend.
- Consider Third-Party or Cloud Solutions
If you are looking for an end-to-end biometric-based access or attendance system, some cloud platforms provide APIs for managing biometric authentication with user IDs.
Example: Platforms like Spintly offer modern, secure solutions for biometric access and attendance tracking. While their primary use case is access control, their APIs might inspire ideas for managing unique user identifiers.
By implementing one of these approaches, you can manage unique user associations securely without relying on Android to generate or expose a unique user ID for biometrics. Let me know if you need further clarification or example code snippets!