FreakyAli / Plugin.Maui.Biometric

A biometric plugin for .NET MAUI
MIT License
106 stars 11 forks source link

Feature request: A method to check the availability of biometric auth #12

Open ExLuzZziVo opened 3 months ago

ExLuzZziVo commented 3 months ago

Hi, Can you please add something like Task<bool> IsAvailableAsync method to the IBiometric interface to check the availability of biometric auth? It is useful for some android devices that doesn't have the fingerprint sensor or the biometric unlock is not set. Currently I check it like this:

(await Plugin.Maui.Biometric.BiometricAuthenticationService.Default.GetEnrolledBiometricTypesAsync()).Count > 0
FreakyAli commented 1 month ago

Sure I will keep this in mind for the future

FreakyAli commented 1 month ago

@ExLuzZziVo Quick question why don't you do something to like:

var biometric = BiometricAuthenticationService.Default;
var enrolledTypes = await biometric.GetEnrolledBiometricTypesAsync();
if(enrolledTypes != BiometricType.None)

That is the same as what you are requesting...

FreakyAli commented 3 weeks ago

@ExLuzZziVo Do you have any updates yet?

ExLuzZziVo commented 3 weeks ago

@FreakyAli, Sorry for such a late reply. If I use the GetEnrolledBiometricTypesAsync() method on the device that doesn't have the fingerprint sensor, it will return the empty collection that doesn't contain the BiometricType.None enum value

FreakyAli commented 3 weeks ago

@ExLuzZziVo try with the latest pre-release you should be able to do it!

ExLuzZziVo commented 3 weeks ago

@FreakyAli On the latest pre-release version it still returns the empty collection. Also I think this collection should be immutable, like Array.