Check if user has configured a screen lock method (PIN/biometric/pattern/etc) using Flutter?
Asked Answered
S

1

6

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?

Saturn answered 7/1, 2021 at 17:23 Comment(0)
B
-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

Burns answered 31/5, 2022 at 0:48 Comment(2)
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_authSapient
those methods from local_auth don't work if the device only has PINHalliday

© 2022 - 2024 — McMap. All rights reserved.