5

I want to check if the user has any type of screen lock set on their device (PIN, fingerprint, face, pattern, etc.).

I don't want to simply check if the device is capable of for example biometrics, nor detect (from the background) if the device is currently locked. I want to know if the user has configured any kind of lock mechanism at all for their device.

All the resources and code snippets I've come across so far seem to focus on

  • checking if the device has biometric capabilities, or
  • actually requesting authentication using biometric/PIN/pattern, or
  • checking if the device is currently locked (when the app is in the background)

I want to simply check if the device has any type of locking configured and required to unlock the phone. If it doesn't, I want to hide some sensitive information in my app.

Is there any way to do this on both Android and iOS?

Magnus
  • 17,157
  • 19
  • 104
  • 189

1 Answers1

-1

To check whether there is local authentication available on this device or not, call canCheckBiometrics (if you need biometrics support) and/or isDeviceSupported() (if you just need some device-level authentication)

https://pub.dev/packages/local_auth

  • `isDeviceSupported()` checks for hardware support. `canCheckBiometrics` checks if fingerprint/iris..etc are enrolled. and `getAvailableBiometrics()` sometimes returns empty [ ] when only pattern is present. so the options are very limited with local_auth – A5H1Q Apr 03 '23 at 05:54
  • those methods from `local_auth` don't work if the device only has PIN – tudorprodan Apr 27 '23 at 08:13