Exemple #1
0
        public async Task <bool> AuthenticateBiometricAsync(string text     = null, string fallbackText = null,
                                                            Action fallback = null)
        {
            if (_deviceActionService.UseNativeBiometric())
            {
                return(await _deviceActionService.AuthenticateBiometricAsync(text));
            }
            else
            {
                try
                {
                    if (text == null)
                    {
                        var supportsFace = await _deviceActionService.SupportsFaceBiometricAsync();

                        text = supportsFace ? AppResources.FaceIDDirection : AppResources.FingerprintDirection;
                    }
                    var fingerprintRequest = new AuthenticationRequestConfiguration(text, text)
                    {
                        CancelTitle   = AppResources.Cancel,
                        FallbackTitle = fallbackText
                    };
                    var result = await CrossFingerprint.Current.AuthenticateAsync(fingerprintRequest);

                    if (result.Authenticated)
                    {
                        return(true);
                    }
                    else if (result.Status == FingerprintAuthenticationResultStatus.FallbackRequested)
                    {
                        fallback?.Invoke();
                    }
                }
                catch { }
                return(false);
            }
        }