如何检查设备是否具有生物特征

问题描述 投票:0回答:1

我通常对Xamarin表单和编码不熟悉,我想在应用启动后立即检查设备是否具有生物特征识别功能。我看到了这段视频,该视频演示了如何使用按钮进行操作,我想在打开应用程序后立即使用它。你可以帮忙吗?

btnFPLogin.Clicked += FingerPrint;

    private async void FingerPrint(object sender, EventArgs e)
            {
                var result = await CrossFingerprint.Current.IsAvailableAsync(true);
                Plugin.Fingerprint.Abstractions.FingerprintAuthenticationResult auth;
                if (result)
                {
                    try
                    {
                        var res = await App.Current.MainPage.DisplayAlert("Success", "Your data are saved", "Ok", "Cancel");
                        auth = await CrossFingerprint.Current.AuthenticateAsync("Authenticate access");
                        if (auth.Authenticated)
                        {
                            await App.Current.MainPage.DisplayAlert("Results are here", "Valid fingerprint found", "Ok");

                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Results are here", "Invalid fingerprint", "Ok");
                        }
                    }
                    catch
                    {
                        await App.Current.MainPage.DisplayAlert("permission to use FaceID", "We need permission to use FaceID", "Ok");
                    }
                }
            }
c# xamarin xamarin.forms xamarin.android xamarin.ios
1个回答
0
投票

您已经回答了自己的问题。要检查设备是否支持生物特征登录,请使用CrossFingerprint插件

var result = await CrossFingerprint.Current.IsAvailableAsync(true);

如果要在应用程序启动时进行检查,请将其放在OnStart类的App方法中

© www.soinside.com 2019 - 2024. All rights reserved.