Closed ilyalehchylin closed 2 years ago
Hi @IlyaLehchylin,
I'm the friendly issue checker. Thanks for using the issue template :star2: I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.
That's how iOS works. It calls the applicationWillResignActive
callback if you start the local authentication. Unfortunately Xamarin.Forms used this callback instead of applicationDidEnterBackground
to trigger it's OnSleep
callback.
Hacky solution (hacky as fuck, no warranty, disclaimer, bad things might happen):
Override the OnResignActivation
and the DidEnterBackground
in your AppDelegate
like this:
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
//CrossFingerprint.AllowReuse = false;
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
public override void OnResignActivation(UIApplication uiApplication)
{
// ignore that stuff
}
public override void DidEnterBackground(UIApplication uiApplication)
{
base.OnResignActivation(uiApplication);
base.DidEnterBackground(uiApplication);
}
}
Better solution
Override DidEnterBackground
and WillEnterForeground
and raise a custom event and ignore OnSleep
and OnResume
on iOS. But then you will miss some events that make the Application inactive.
protected override void OnSleep()
{
if (Device.RuntimePlatform != Device.iOS)
{
Debug.WriteLine("OnSleep");
}
}
Steps to reproduce
Use fingerprint method AuthenticateAsync.
Add Debug.WriteLine(message) in OnSleep and OnResume methods (Xamarin.Forms).
Authenticate with finger.
Expected behavior
OnSleep and OnResume methods are not called.
Actual behavior
OnSleep and OnResume methods are called. In my case OnSleep and OnResume are used to check when the app is inactive. So you log in with your finger, OnSleep and OnResume are called, then you go back to the previous page and log in again and so on.
Crashlog
There is no crashlog.
Configuration
Version of the Plugin: 1.4.6-beta4
Platform: iOS 11.2 (I guess Android works the same)
Device: iPhone 8 Plus (Device), iPhone 8 (Simulator)