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

时间:2020-03-02 18:21:25

标签: c# xamarin xamarin.forms xamarin.android xamarin.ios

我一般都不熟悉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");
                    }
                }
            }

1 个答案:

答案 0 :(得分:0)

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

OnStart

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