Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakim Gulam Ali authored and Hakim Gulam Ali committed Dec 13, 2024
1 parent e7c4492 commit 55beb31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public partial Task<BiometricType[]> GetEnrolledBiometricTypesAsync()
if(canAuthenticate == BiometricManager.BiometricErrorNoneEnrolled)
{
availableOptions[0] = BiometricType.None;
availableOptions[0] = BiometricType.None;
availableOptions[1] = BiometricType.None;
}
if (canAuthenticate == BiometricManager.BiometricSuccess)
{
Expand All @@ -129,8 +129,6 @@ public partial Task<BiometricType[]> GetEnrolledBiometricTypesAsync()
availableOptions[1] = BiometricType.None;
}
}
Debug.WriteLine(availableOptions[0]);
Debug.WriteLine(availableOptions[1]);
}
return Task.FromResult(availableOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,16 @@ public async partial Task<AuthenticationResponse> AuthenticateAsync(Authenticati
public partial Task<BiometricType[]> GetEnrolledBiometricTypesAsync()
{
var localAuthContext = new LAContext();
var availableOptions = new BiometricType[2];
var availableOptions = new BiometricType[2] { BiometricType.None, BiometricType.None };
if (localAuthContext.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var _))
{
var isFace = localAuthContext.BiometryType == LABiometryType.FaceId;
var isFingerprint = localAuthContext.BiometryType == LABiometryType.TouchId;
if (isFace)
{
availableOptions[0] = (BiometricType.Face);
}
if (isFingerprint)
{
availableOptions[1] = (BiometricType.Fingerprint);
}
if (!isFace && !isFingerprint)

if (isFace || isFingerprint)
{
availableOptions[0] = (BiometricType.None);
availableOptions[1] = (BiometricType.None);
availableOptions[0] = isFace ? BiometricType.Face : BiometricType.None;
availableOptions[1] = isFingerprint ? BiometricType.Fingerprint : BiometricType.None;
}
}
return Task.FromResult(availableOptions);
Expand Down
8 changes: 6 additions & 2 deletions Plugin.Maui.Biometric/Samples/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Plugin.Maui.Biometric;
using System.Diagnostics;
using Plugin.Maui.Biometric;

namespace Samples;

Expand All @@ -16,7 +17,10 @@ private async void OnCounterClicked(object sender, EventArgs e)
{
//get a list of enrolled biometric types
var enrolledTypes = await biometric.GetEnrolledBiometricTypesAsync();

foreach(var item in enrolledTypes)
{
Console.WriteLine(item.ToString());
}
//get current status of the hardware
var result = await biometric.GetAuthenticationStatusAsync(AuthenticatorStrength.Weak);
if (result == BiometricHwStatus.Success)
Expand Down

0 comments on commit 55beb31

Please sign in to comment.