简体   繁体   中英

FingerPrint Authentication in Xamarin form

I am having a login form and implementing fingerprint authentication. I have the following code but the app crashes suddenly.

Button in xml file:

<Button Text="Scan Fingerprint" Clicked="FingerPrint_clicked"/>

Code behind this:

public async void FingerPrint_clicked(object sender, EventArgs e)
{
        var cancellationToken = new System.Threading.CancellationToken();
        var scanResult = await CrossFingerprint.Current.AuthenticateAsync("Show your fingerprint", cancellationToken);
        if(scanResult.Authenticated)
        {
            await DisplayAlert(null, "done", "ok");
        }
        else
        {
            await DisplayAlert(null, "failed", "ok");
        }
}

MainActivity.cs

CrossFingerprint.SetCurrentActivityResolver(()=> CrossCurrentActivity.Current.Activity);

Added fingerprint in android.manifest file and set fingerprint in emulator too

Upon clicking the button for fingerprint test, the app crashes suddenly.

通过将此行添加到MainActivity.cs文件来解决:

 CrossCurrentActivity.Current.Init(this, savedInstanceState);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM