expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
34.74k stars 5.57k forks source link

Does LocalAuthentication support facial recognition? #11359

Closed schmru closed 3 years ago

schmru commented 3 years ago

SDK Version: 38.0.8 Platforms(Android/iOS/web/all): Android 10 Hello, I am trying to implement facial recognition with LocalAuthentication for my app. My coworker has Samsung Galaxy A70 which he can unlock using facial recognition, but when it comes to my app it says he only has fingerprint supported. I added USE_BIOMETRIC to AndroidManifest but and am trying this on expo client.

Should I build an apk so that we can test this or should I add something else to the code, so that the application will recognise he also has facial recognition avaliable?

AdamJNavarro commented 3 years ago

Hey @schmru, if the device has facial recognition support than the LocalAuthentication module should recognize this. You can use the supportedAuthenticationTypesAsync method to check. https://docs.expo.io/versions/v40.0.0/sdk/local-authentication/#localauthenticationsupportedauthenticationtypesasync Also make sure that the device is enrolled (has fingerprint or facial data enabled).

I'm going to close this issue. For future reference, please direct questions like this one to our forums as we keep github issues reserved for reproducible and actionable bug reports. If you find that the device is enrolled and has facial recognition support but the module says otherwise, we can re-open this issue.

Cheers, Adam

mattiascaricato commented 3 years ago

@AdamJNavarro in Android when you have both, touch id and face id configured, the authenticateAsync method it only asks for finger id. That being said, is there any way to define what is the biometric method I wanna use? The only way I could make face id work is removing my fingers configured in my phone, so when I call authenticateAsync it uses face id. I don't think this is the expected behavior, any idea?

WolfyUK commented 3 years ago

@mattiascaricato Agreed. I'm not sure this issue should be closed. On Android, the results returned from supportedAuthenticationTypesAsync() are not always the same as the user has actually configured. This may be replicated with Samsung Galaxy S8 devices too but I'm unable to confirm if it's a Samsung-only issue as Huawei devices were also being weird.

The only time I've ever seen FACIAL_RECOGNITION come back from the call above on Android is on a Google Pixel 4 device that does not have a fingerprint scanner. I think that there may be some additional configuration or permissions required somewhere in order to resolve this but I guess that's up to the Expo guys to comment on. For the moment we're going to have to change phrasing across our app to assume that supportedAuthenticationTypesAsync() is inaccurate on Android and instead use something more generic.

I modified some existing Snacks to verify this on both Expo 39 and 40:

WolfyUK commented 3 years ago

There seems to be a similar discussion on https://github.com/expo/expo/issues/7838 with a potential fix mentioned in version 9.2.0 of expo-local-authentication, but the Snacks above use 9.3.0 to no avail.