Example #1
0
        public void Authenticate(Action successAction, Action failAction)
        {
            NSError AuthError;

            if (_context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler(async(success, error) =>
                {
                    if (success)
                    {
                        await GlobalObject.curMainPage.Navigation.PushAsync(new MainPage());
                    }
                    else
                    {
                        //Show fallback mechanism here
                        if (failAction != null)
                        {
                            failAction.Invoke();
                        }
                    }
                });
                _context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Fingerprint Authentication", replyHandler);
            }
            ;
        }
        public Task <OperationResult> PerformBiometricAuthentication(string promptText)
        {
            var tcs = new TaskCompletionSource <OperationResult>();

            var     context = new LAContext();
            NSError authError;
            var     message = new NSString(promptText);

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    if (success)
                    {
                        tcs.SetResult(OperationResult.AsSuccess());
                    }
                    else
                    {
                        tcs.SetResult(OperationResult.AsFailure((error as NSError).LocalizedDescription));
                    }
                });

                // This starts the authentication dialog.
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, message, replyHandler);
            }
            return(tcs.Task);
        }
        /// <summary>
        /// Prompts for touch id authenticaion.
        /// </summary>
        /// <param name="responseAction">Code to execute after a response is received from Touch ID.</param>
        public static LAContext PromptForTouchID(LAContextReplyHandler responseAction)
        {
            var context = new LAContext();

            context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Logging in with Touch ID", responseAction);
            return(context);
        }
Example #4
0
        public void Authenticate(Action successAction, Action failAction)
        {
            _context = new LAContext();
            NSError AuthError;

            if (_context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) => {
                    if (success)
                    {
                        if (successAction != null)
                        {
                            successAction.Invoke();
                        }
                    }
                    else
                    {
                        //Show fallback mechanism here
                        if (failAction != null)
                        {
                            failAction.Invoke();
                        }
                    }
                });
                _context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Fingerprint Authentication", replyHandler);
            }
            ;
        }
Example #5
0
        partial void AuthenticateMe(UIButton sender)
        {
            var     context = new LAContext();
            NSError AuthError;
            var     localizedReason = new NSString("To add a new chore");

            //Use canEvaluatePolicy method to test if device is TouchID enabled
            //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                replyHandler = new LAContextReplyHandler((success, error) => {
                    //Make sure it runs on MainThread, not in Background
                    this.InvokeOnMainThread(() => {
                        if (success)
                        {
                            Console.WriteLine("You logged in!");
                            PerformSegue("AuthenticationSegue", this);
                        }
                        else
                        {
                            //Show fallback mechanism here
                            unAuthenticatedLabel.Text = "Oh Noes";
                            AuthenticateButton.Hidden = true;
                        }
                    });
                });
                //Use evaluatePolicy to start authentication operation and show the UI as an Alert view
                //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
            }
            ;
        }
		public FingerprintAuthenticationResponse Authenticate ()
		{
			_reachedCallBackEvent = new ManualResetEvent(false);

			FingerprintAuthenticationResponse response = FingerprintAuthenticationResponse.Failed;
			
			LAContextReplyHandler replyHandler = new LAContextReplyHandler((success, error) => {
				if(success){
					Debug.WriteLine("Successfully authenticated using TouchID");
					response = FingerprintAuthenticationResponse.Accepted;
				}
				else{
					if(error.Code == -2){ //-2 is error code when cancelled by user
						Debug.WriteLine ("User cancelled to authenticate using TouchID");
						response = FingerprintAuthenticationResponse.Cancelled;
					}
					else {
						Debug.WriteLine ("Failed to authenticate using TouchID");
						response = FingerprintAuthenticationResponse.Failed;
					}
				}
				_reachedCallBackEvent.Set();
			});

			//Use evaluatePolicy to start authentication operation and show the UI as an Alert view
			//Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
			_context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, new NSString("Leg uw vinger op de vingerafdruk scanner om uzelf te authenticeren"), replyHandler);

			_reachedCallBackEvent.WaitOne();

			return response;
		}
Example #7
0
        void PerformAuthentication(object sender, EventArgs e)
        {
            NSError authError;
            var     context = new LAContext();

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) => this.InvokeOnMainThread(() => {
                    if (success)
                    {
                        PerformSegue("AuthScreen", this);
                    }
                    else
                    {
                        UIAlertController uac = UIAlertController.Create("Authentication Failed. Is this your phone?", "Security Failure", UIAlertControllerStyle.Alert);
                        uac.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                        this.PresentViewController(uac, true, null);
                    }
                }));

                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Access Account", replyHandler);
            }
            else
            {
                UIAlertController uac = UIAlertController.Create("Biometrics not supported", "Policy not supported", UIAlertControllerStyle.Alert);
                uac.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                this.PresentViewController(uac, true, null);
            }
        }
		partial void AuthenticateMe (UIButton sender)
		{
			var context = new LAContext();
			NSError AuthError;
			var localizedReason = new NSString("To add a new chore");

			//Use canEvaluatePolicy method to test if device is TouchID enabled
			//Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
			if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)){
				replyHandler = new LAContextReplyHandler((success, error) => {
					//Make sure it runs on MainThread, not in Background
					this.InvokeOnMainThread(()=>{
						if(success){
							Console.WriteLine("You logged in!");
							PerformSegue("AuthenticationSegue", this);
						}
						else{
							//Show fallback mechanism here
							unAuthenticatedLabel.Text="Oh Noes";
							AuthenticateButton.Hidden= true;
						}
					});

				});
				//Use evaluatePolicy to start authentication operation and show the UI as an Alert view
				//Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
				context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
			};
		}
Example #9
0
        void AuthenticateThroughFingerprint()
        {
            var     context = new LAContext();
            NSError authError;
            var     myReason = new NSString(
                "Please, provide your fingerprint to acess the app.");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    this.InvokeOnMainThread(async() =>
                    {
                        if (success)
                        {
                            return;
                        }

                        var dialogService = Mvx.Resolve <IDialogService>();
                        await dialogService.AlertAsync(
                            "We could not detect your fingerprint. " +
                            "You will be asked again to enter your Azure AD credentials. " +
                            "Thank you.",
                            "Touch ID",
                            "OK");

                        // If fingerprint not detected, repeat Azure AD auth.
                        AuthenticateThroughAzureADAndAddFingerprintAsync()
                        .ConfigureAwait(false);
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
            }
        }
Example #10
0
        public Task <bool> AuthenticateUserIDWithTouchID()
        {
            bool outcome = false;
            var  tcs     = new TaskCompletionSource <bool>();

            var context = new LAContext();

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) => {
                    Device.BeginInvokeOnMainThread(() => {
                        if (success)
                        {
                            outcome = true;
                        }
                        else
                        {
                            outcome = false;
                        }
                        tcs.SetResult(outcome);
                    });
                });
                //This will call both TouchID and FaceId
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Login with touch ID", replyHandler);
            }
            ;
            return(tcs.Task);
        }
        public void AuthenticateMe()
        {
            var     context = new LAContext();
            NSError AuthError;
            var     myReason = new NSString("Log in to proceed");


            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) => {
                    this.InvokeOnMainThread(() => {
                        if (success)
                        {
                            Console.WriteLine("You logged in!");
                            UIApplication.SharedApplication.KeyWindow.RootViewController = AppDelegate.CachedViewController;
                        }
                        else
                        {
                            //Show fallback mechanism here
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
            }
            ;
        }
 partial void btnTouchId_TouchUpInside(UIButton sender)
 {
     //Lets double check the device supports Touch ID
     if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out error))
     {
         var replyHandler = new LAContextReplyHandler((success, error) =>
         {
             InvokeOnMainThread(() =>
             {
                 if (success)
                 {
                     var newVC = new UIViewController();
                     PresentViewController(newVC, true, null);
                 }
                 else
                 {
                     var alert = new UIAlertView("OOPS!", "Something went wrong.", null, "Oops", null);
                     alert.Show();
                 }
             });
         });
         context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Logging in with Touch ID", replyHandler);
     }
     else
     {
         var alert = new UIAlertView("Error", "TouchID not available", null, "BOOO!", null);
         alert.Show();
     }
 }
Example #13
0
        public Task <bool> LoginAsync()
        {
            LAContextReplyHandler replyHandler;

            var retVal = new TaskCompletionSource <bool>();

            var     context = new LAContext();
            NSError AuthError;

            var localizedReason = new NSString("Access to STATAlert");

            // because LocalAuthentication APIs have been extended over time, need to check iOS version before setting some properties
            context.LocalizedFallbackTitle = "Fallback"; // iOS 8

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                context.LocalizedCancelTitle = "Cancel"; // iOS 10
            }
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                context.LocalizedReason = "Authorize for access to STATAlert"; // iOS 11
                BiometryType            = context.BiometryType == LABiometryType.TouchId ? "TouchID" : "FaceID";
            }

            //Use canEvaluatePolicy method to test if device is TouchID or FaceID enabled
            //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                Console.WriteLine("TouchID/FaceID available/enrolled");
                replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background

                    Xamarin.Essentials.MainThread.BeginInvokeOnMainThread(
                        () =>
                    {
                        if (success)
                        {
                            retVal.SetResult(success);
                        }
                        else
                        {
                            Console.WriteLine(error.LocalizedDescription);
                            retVal.SetResult(success);
                        }
                    });
                });

                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
            }

            return(retVal.Task);
        }
Example #14
0
        public void AuthenticateWithTouchId(LoginPage page)
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                return;
            }

            var hasLoginKey = NSUserDefaults.StandardUserDefaults.BoolForKey("hasLogin");

            if (string.IsNullOrEmpty(App.UserName))
            {
                return;
            }

            var username = NSUserDefaults.StandardUserDefaults.ValueForKey(new NSString("username")).ToString();

            if (string.IsNullOrEmpty(username))
            {
                return;
            }

            var     context = new LAContext();
            NSError AuthError;
            var     myReason = new NSString("Login to expense portal");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    if (error != null)
                    {
                        if (error.LocalizedDescription == "Canceled by user.")
                        {
                            return;
                        }
                    }

                    if (success)
                    {
                        Console.WriteLine("Success!!");
                        var userName = NSUserDefaults.StandardUserDefaults.ValueForKey(new NSString("username")).ToString();

                        Xamarin.Insights.Identify(userName, new Dictionary <string, string> {
                            { "User Type", "NonApprover" },
                        });
                    }

                    page.TouchIdSuccess = success;
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
            }
            ;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            authenticationButton.TouchUpInside += (sender, e) =>
            {
                var context = new LAContext();
                var result  = context.EvaluatePolicyAsync(LAPolicy.DeviceOwnerAuthentication, "Authentication Request").GetAwaiter().GetResult();

                var can = context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out Foundation.NSError error);

                if (result.Item1)
                {
                    UserDialogs.Instance.Alert("Authentication");
                }
                else
                {
                    var code   = Convert.ToInt16(result.Item2.Code);
                    var status = (LAStatus)code;
                    UserDialogs.Instance.Alert(status.ToString());
                }
            };

            authenButton.TouchUpInside += (sender, e) =>
            {
                var context  = new LAContext();
                var myReason = new NSString("To add a new chore");

                if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError AuthError))
                {
                    var replyHandler = new LAContextReplyHandler((success, error) => {
                        this.InvokeOnMainThread(() => {
                            if (success)
                            {
                                UserDialogs.Instance.Alert("Login Success");
                            }
                            else
                            {
                                //Show fallback mechanism here
                            }
                        });
                    });
                    context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
                }
                ;
            };
        }
Example #16
0
        public Task <bool> GetAuthentication()
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            LAContext context = new LAContext();
            NSString  caption = new NSString("Login to tSecret");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError ae))
            {
                LAContextReplyHandler replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    tcs.SetResult(success);
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, caption, replyHandler);
            }
            ;
            return(tcs.Task);
        }
Example #17
0
    private LAContextReplyHandler GetReplyHandler(Func <Task> action)
    {
        var replyHandler = new LAContextReplyHandler((success, error) =>
        {
            if (success)
            {
                action();
                OnBiometrics = false;
            }
            else
            {
                OnBiometrics = false;
            }
        });

        return(replyHandler);
    }
Example #18
0
        public bool Authenticted()
        {
            var     context = new LAContext();
            NSError AuthError;
            var     localizedReason = new NSString("To access secrets");

            // because LocalAuthentication APIs have been extended over time, need to check iOS version before setting some properties
            context.LocalizedFallbackTitle = "Fallback"; // iOS 8

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                context.LocalizedCancelTitle = "Cancel"; // iOS 10
            }
            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                Console.WriteLine("TouchID/FaceID available/enrolled");
                replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background
                    this.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            //Console.WriteLine($"You logged in with {BiometryType}!");

                            //PerformSegue("AuthenticationSegue", this);
                            IsValidFace = true;
                        }
                        else
                        {
                            IsValidFace = false;
                            //Console.WriteLine(error.LocalizedDescription);
                            //Show fallback mechanism here
                            //unAuthenticatedLabel.Text = $"{BiometryType} Authentication Failed";
                            //AuthenticateButton.Hidden = true;
                        }
                    });
                });
                //Use evaluatePolicy to start authentication operation and show the UI as an Alert view
                //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
                return(IsValidFace);
            }
            return(IsValidFace);
        }
Example #19
0
        /// <inheritdoc />
        public Task <AuthenticationResult> AuthenticateAsync(string alertMessage = null)
        {
            if (AvailableBiometricType == BiometricType.None)
            {
                Logger.Debug("[BiometricAthenticationService] Authentication not available on this device");
                return(Task.FromResult(new AuthenticationResult(false, "Authentication not available")));
            }

            var tcs = new TaskCompletionSource <AuthenticationResult>();

            var     context = new LAContext();
            NSError authError;

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError) ||
                context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background
                    UIApplication.SharedApplication.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            System.Diagnostics.Debug.WriteLine("Authentication Success");
                            tcs.TrySetResult(new AuthenticationResult(true));
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Authentication Failure : " + error.Description);
                            tcs.TrySetResult(new AuthenticationResult(false, error.Description));
                        }
                    });
                });

                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, alertMessage ?? "Please scan fingerprint", replyHandler);
            }
            else
            {
                //No Auth setup on Device
                Logger.Debug($"This device doesn't have authentication configured: {authError.ToString()}");
                tcs.TrySetResult(new AuthenticationResult(false, "This device does't have authentication configured."));
            }

            return(tcs.Task);
        }
		partial void LoginButtonOnUpInside (UIButton sender)
		{
			if (!PerformValidation ()) {
				return;
			}
				
			var context = new LAContext();
			NSError AuthError;
			if (context.CanEvaluatePolicy (LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)) {
				var replyHandler = new LAContextReplyHandler((success, error) => InvokeOnMainThread (() => {
					if (success) {
						AttemptLogin();
					} 
				}));
				context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Logging in with Touch ID", replyHandler);
			} else {
				AttemptLogin();
			}
		}
        /// <summary>
        /// Views the will appear.
        /// </summary>
        /// <param name="animated">If set to <c>true</c> animated.</param>
        public override void ViewWillAppear(bool animated)
        {
            //get user connection profile
            ConnectionProfile connectionProfile = ConnectionHelper.GetConnectionProfile();

            if (connectionProfile == null)
            {
                return;
            }

            //create nre Local Auth context
            var     laContext = new LAContext();
            NSError AuthError;

            var authReason = new NSString("Connect to pet la forme");

            //if can evaluate policy with biometrics (FACE/TOUCH ID)
            if (laContext.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                //new reply handler
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    this.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            Auth(connectionProfile);
                        }
                        else
                        {
                            Console.WriteLine("Auth fail");
                        }
                    });
                });
                //evaluate policy in actual local context
                laContext.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, authReason, replyHandler);
            }
            else
            {
                //also connect user because ios simulator don't have secret code and biometrics
                Auth(connectionProfile);
            }
        }
Example #22
0
        private void AddFingerprintAuthentication()
        {
            var     context = new LAContext();
            NSError authError;
            var     myReason = new NSString(
                "Please, provide your fingerprint to simplify the authentication.");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    this.InvokeOnMainThread(() =>
                    {
                        var dialogService = Mvx.Resolve <IDialogService>();

                        if (success)
                        {
                            Settings.TouchIdEnrolledAndFingerprintDetected = true;

                            dialogService.AlertAsync(
                                "Your fingerprint was successfully detected. " +
                                "You can access the app through it from now on. " +
                                "Thank you.",
                                "Touch ID",
                                "OK");
                        }
                        else
                        {
                            Settings.TouchIdEnrolledAndFingerprintDetected = false;

                            dialogService.AlertAsync(
                                "We could not detect your fingerprint. " +
                                "You will need to authenticate through Azure AD. " +
                                "Thank you.",
                                "Touch ID",
                                "OK");
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
            }
        }
partial         void UIButton5_TouchUpInside(UIButton sender)
        {
            var context = new LAContext ();

            var error = new NSError ();

            if (context.CanEvaluatePolicy (LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error)) {

                var replyHandler = new LAContextReplyHandler((success, err) => {
                    this.InvokeOnMainThread(() => {
                        if(success){
                            new UIAlertView("Success", "You logged in", null, "Close").Show();
                        } else {
                            new UIAlertView("Login Error", err.LocalizedDescription, null, "Close").Show();
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "You need to login", replyHandler);
            }
        }
        void LaunchTouchID()
        {
            var     context = new LAContext();
            NSError AuthError;
            var     reason = new NSString("Security validation");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    this.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            DismissViewController(false, null);
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, reason, replyHandler);
            }
        }
Example #25
0
        public static void Authenticate(Action onSuccess, Action onFailure)
        {
            var     context = new LAContext();
            NSError AuthError;

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError) ||
                context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    if (success)
                    {
                        onSuccess?.Invoke();
                    }
                    else
                    {
                        onFailure?.Invoke();
                    }
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, Strings.PleaseAuthenticateToProceed, replyHandler);
            }
        }
Example #26
0
        public void Authenticate(string userId, Action onSuccess, Action onFailure)
        {
            var context = new LAContext();

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError AuthError) ||
                context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    if (success)
                    {
                        onSuccess?.Invoke();
                    }
                    else
                    {
                        onFailure?.Invoke();
                    }
                });

                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, $"Sign in with Online Id for {userId}", replyHandler);
            }
        }
        partial void UIButton5_TouchUpInside(UIButton sender)
        {
            var context = new LAContext();

            var error = new NSError();

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error))
            {
                var replyHandler = new LAContextReplyHandler((success, err) => {
                    this.InvokeOnMainThread(() => {
                        if (success)
                        {
                            new UIAlertView("Success", "You logged in", null, "Close").Show();
                        }
                        else
                        {
                            new UIAlertView("Login Error", err.LocalizedDescription, null, "Close").Show();
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "You need to login", replyHandler);
            }
        }
        void LaunchTouchID()
        {
            var     context = new LAContext();
            NSError AuthError;
            var     reason = new NSString("Security validation");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    this.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            //go to initial page
                            UIViewController uiview = Storyboard.InstantiateViewController("MainViewController");
                            PresentViewController(uiview, false, null);
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, reason, replyHandler);
            }
        }
        public void FaceAuthentication()
        {
            var     context  = new LAContext();
            var     myReason = new NSString("Athenticate");
            NSError AuthError;

            //Check if Face ID is available on mobile device.
            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) => {
                    Device.BeginInvokeOnMainThread(() => {
                        //If authetification is successfull navigate to Select Type page.

                        //If authentication is successful continue to next page.
                        if (success)
                        {
                            if (count > 0)                             // If record count for User table is > 0 then an account exist
                            {
                                Xamarin.Forms.Application.Current.MainPage = new Home();
                            }
                            else                             // If the record count is 0 then no User account exist
                            {
                                Xamarin.Forms.Application.Current.MainPage = new SelectType();
                            }
                        }
                    });
                });

                //Handle the result of Face ID authentification (Sucess/Failure) according to replyHandler above.
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
            }
            else
            {
                //If FaceID NOT available on mobile device, display appropriate error message.
                Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Authentication Failed", "Could not Authenticate with FaceID", "Ok");
            }
        }
Example #30
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        public static void AuthenticateUser(MvxViewController controller)
        {
            var     viewModel = (AuthenticationViewModel)controller.ViewModel;
            var     context   = new LAContext();
            NSError AuthError;
            var     authenticationReason = new NSString("Authentication is needed to access the application");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    controller.InvokeOnMainThread(() =>
                    {
                        if (viewModel != null)
                        {
                            if (success)
                            {
                                //Calling the success handler
                                viewModel.OnAuthenticationSuccess();
                                Console.WriteLine("You logged in!");
                            }
                            else
                            {
                                //Calling the failure handler
                                viewModel.OnAuthenticationFailure();
                            }
                        }
                    });
                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, authenticationReason, replyHandler);
            }
            else
            {
                viewModel.OnAuthenticationFailure();
            }
        }
partial         void btnLogin_TouchUpInside(UIButton sender)
        {
            NSError _error;

            using (var _context = new LAContext ()) {

                // Allows us to reuse Touch ID verificaton from unlocking device up to 30 seconds later
                _context.TouchIdAuthenticationAllowableReuseDuration = 30;

                if (_context.CanEvaluatePolicy (LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out _error)) {

                    // Get enrollment state
                    if (_context.EvaluatedPolicyDomainState != null) {
                        var policyState = _context.EvaluatedPolicyDomainState.ToString().Replace("<", "").Replace(">", "").Replace(" ", "");

                        if (TouchIDPolicyDomainState != null)
                        {
                            if (policyState != TouchIDPolicyDomainState)
                                Console.WriteLine("Fingerprints enrollments changed.");
                            else
                                Console.WriteLine("Fingerprints enrollments remain the same.");
                        }

                        // Store enrollment
                        TouchIDPolicyDomainState = policyState;
                    }

                    var replyHandler = new LAContextReplyHandler ((success, error) => {
                        InvokeOnMainThread (() => {

                            if (success) {
                                PerformSegue("SegueToTest", null);
                            } else {
                                DisplayAlertOKPopup("", "Unable to authenticate.");
                            }
                        });
                    });

                    // Add reason why we are using Touch ID
                    _context.EvaluatePolicy (LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Login as user: X", replyHandler);
                } else {
                    DisplayAlertOKPopup("", "Touch ID not available on this device.");
                }
            }
        }
Example #32
0
        void AuthenticateMe(object sender, EventArgs ea)
        {
            var     context = new LAContext();
            NSError AuthError;
            var     localizedReason = new NSString("To access secrets");

            // because LocalAuthentication APIs have been extended over time, need to check iOS version before setting some properties
            context.LocalizedFallbackTitle = "Fallback"; // iOS 8

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                context.LocalizedCancelTitle = "Cancel"; // iOS 10
            }
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                context.LocalizedReason = "Authorize for access to secrets"; // iOS 11
                BiometryType            = context.BiometryType == LABiometryType.TouchId ? "TouchID" : "FaceID";
            }

            //Use canEvaluatePolicy method to test if device is TouchID or FaceID enabled
            //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                Console.WriteLine("TouchID/FaceID available/enrolled");
                replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background
                    InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            Console.WriteLine($"You logged in with {BiometryType}!");

                            Nav.Authenticated = true;
                            DismissViewController(true, null);
                        }
                        else
                        {
                            Console.WriteLine(error.LocalizedDescription);
                            //Show fallback mechanism here
                            LoginLabel.Text = $"{BiometryType} Authentication Failed";
                            //LoginButton.Hidden = true;
                        }
                    });
                });
                //Use evaluatePolicy to start authentication operation and show the UI as an Alert view
                //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
            }
            else if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out AuthError))
            {
                Console.WriteLine("When TouchID/FaceID aren't available or enrolled, use the device PIN");
                replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background
                    InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            Console.WriteLine($"You logged in with {BiometryType}!");

                            Nav.Authenticated = true;
                            DismissViewController(true, null);
                        }
                        else
                        {
                            Console.WriteLine(error.LocalizedDescription);
                            //Show fallback mechanism here
                            LoginLabel.Text = "Device PIN Authentication Failed";
                            //LoginButton.Hidden = true;
                        }
                    });
                });
                //Use evaluatePolicy to start authentication operation and show the UI as an Alert view
                //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, localizedReason, replyHandler);
            }
            else
            {
                // User hasn't configured a PIN or any biometric auth.
                // App may implement its own login, or choose to allow open access
                //unAuthenticatedLabel.Text = "No device auth configured";

                var okCancelAlertController = UIAlertController.Create("No authentication", "This device does't have authentication configured.", UIAlertControllerStyle.Alert);
                okCancelAlertController.AddAction(UIAlertAction.Create("Use unsecured", UIAlertActionStyle.Default, alert => DismissViewController(true, null)));
                okCancelAlertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, alert => Console.WriteLine("Cancel was clicked")));
                PresentViewController(okCancelAlertController, true, null);
            }
        }
Example #33
0
        public void EscanearHuella()
        {
            try
            {
                var     context = new LAContext();
                NSError AuthError;
                var     localizedReason = new NSString("Por favor, coloque su dedo en el sensor");
                context.LocalizedFallbackTitle = "";

                bool touchIDSetOnDevice = context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError);

                //Use el método canEvaluatePolicy para probar si el dispositivo está habilitado para TouchID
                if (touchIDSetOnDevice)
                {
                    replyHandler = new LAContextReplyHandler((success, error) => {
                        //Asegúrese de que se ejecute en el hilo principal, no en el fondo
                        this.InvokeOnMainThread(() => {
                            if (success)
                            {
                                //Se ejecuta cuando la validación de la huella fue exitosa
                                Xamarin.Forms.Application.Current.MainPage.Navigation.PushModalAsync(new MainPage());
                            }
                            else
                            {
                                //Se ejecuta cuando no se pudo validar la huella
                                if (!error.LocalizedDescription.Equals("Canceled by user."))
                                {
                                    if (error.LocalizedDescription.Equals("Application retry limit exceeded."))
                                    {
                                        Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Atención", "Sólo le restan 2 intentos. ¿Seguro que desea continuar?", "Aceptar");
                                    }
                                    if (error.LocalizedDescription.Equals("Biometry is locked out."))
                                    {
                                        Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Atención", "Por su seguridad, su ingreso mediante huella dactilar fue desactivado.", "Aceptar");
                                    }
                                }
                            }
                        });
                    });
                    //Utilice evaluatePolicy para iniciar la operación de autenticación y mostrar la interfaz de usuario como una vista de alerta
                    context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
                }
                else
                {
                    if ((LAStatus)Convert.ToInt16(AuthError.Code) == LAStatus.TouchIDNotAvailable)
                    {
                        Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Atención", "Ingreso mediante huella dactilar no disponible.", "Aceptar");
                    }
                    else if ((LAStatus)Convert.ToInt16(AuthError.Code) == LAStatus.TouchIDNotEnrolled)
                    {
                        Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Atención", "No hay huellas dactilares registradas.", "Aceptar");
                    }
                    else if ((LAStatus)Convert.ToInt16(AuthError.Code) == LAStatus.BiometryNotAvailable)
                    {
                        Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Atención", "Este dispositivo no soporta la autenticación de huella dactilar.", "Aceptar");
                    }
                    //if((LAStatus)Convert.ToInt16(AuthError.Code) == LAStatus.BiometryNotEnrolled)
                    //Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Atención", "El usuario no se ha inscrito para la autenticación de huella dactilar.", "Aceptar");
                    else
                    {
                        HabilitarTecladoDesbloqueo();
                    }
                }
            }
            catch (Exception ex)
            {
                var e = ex;
            }
        }
 partial void btnTouchId_TouchUpInside(UIButton sender)
 {
     //Lets double check the device supports Touch ID
     if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out error))
     {
         var replyHandler = new LAContextReplyHandler((success, error) =>
             {
                 InvokeOnMainThread(() =>
                     {
                         if (success)
                         {
                             var newVC = new UIViewController();
                             PresentViewController(newVC, true, null);
                         }
                         else
                         {
                             var alert = new UIAlertView("OOPS!", "Something went wrong.", null, "Oops", null);
                             alert.Show();
                         }
                     });
             });
         context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Logging in with Touch ID", replyHandler);
     }
     else
     {
         var alert = new UIAlertView("Error", "TouchID not available", null, "BOOO!", null);
         alert.Show();
     }
             
 }
Example #35
0
        public Task <bool> AuthenticateMe()
        {
            var     context = new LAContext();
            NSError AuthError;
            var     localizedReason = new NSString("To access secrets");

            // because LocalAuthentication APIs have been extended over time, need to check iOS version before setting some properties
            context.LocalizedFallbackTitle = "Fallback"; // iOS 8

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                context.LocalizedCancelTitle = "Cancel"; // iOS 10
            }
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                context.LocalizedReason = "Authorize for access to secrets"; // iOS 11
                BiometryType            = context.BiometryType == LABiometryType.TouchId ? "TouchID" : "FaceID";
            }

            var tcs = new TaskCompletionSource <bool>();

            //Use canEvaluatePolicy method to test if device is TouchID or FaceID enabled
            //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                Console.WriteLine("TouchID/FaceID available/enrolled");
                replyHandler = new LAContextReplyHandler((success, error) => {
                    //Make sure it runs on MainThread, not in Background
                    UIApplication.SharedApplication.InvokeOnMainThread(() => {
                        if (success)
                        {
                            Console.WriteLine($"You logged in with {BiometryType}!");
                            tcs.SetResult(success);
                            //PerformSegue("AuthenticationSegue", this);
                        }
                        else
                        {
                            Console.WriteLine(error.LocalizedDescription);
                            //Show fallback mechanism here
                            tcs.SetResult(success);
                            tcs.SetException(new Exception(error.Description));
                        }
                    });
                });
                //Use evaluatePolicy to start authentication operation and show the UI as an Alert view
                //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
            }
            else if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out AuthError))
            {
                Console.WriteLine("When TouchID/FaceID aren't available or enrolled, use the device PIN");
                replyHandler = new LAContextReplyHandler((success, error) => {
                    //Make sure it runs on MainThread, not in Background
                    UIApplication.SharedApplication.InvokeOnMainThread(() => {
                        if (success)
                        {
                            Console.WriteLine($"You logged in with {BiometryType}!");
                            //PerformSegue("AuthenticationSegue", this);
                            tcs.SetResult(success);
                        }
                        else
                        {
                            Console.WriteLine(error.LocalizedDescription);
                            //Show fallback mechanism here
                            tcs.SetResult(success);
                            tcs.SetException(new Exception(error.Description));
                        }
                    });
                });
                //Use evaluatePolicy to start authentication operation and show the UI as an Alert view
                //Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, localizedReason, replyHandler);
            }
            else
            {
                // User hasn't configured a PIN or any biometric auth.
                // App may implement its own login, or choose to allow open access
                tcs.SetResult(false);
            }

            return(tcs.Task);
        }
Example #36
0
        /// <inheritdoc />
        public Task <AuthenticationResult> AuthenticateAsync(string alertMessage = null)
        {
            if (AvailableBiometricType == BiometricType.None)
            {
                Console.WriteLine("[BiometricAthenticationService] Authentication not available on this device");
                return(Task.FromResult(new AuthenticationResult(false, "Authentication not available")));
            }

            var tcs = new TaskCompletionSource <AuthenticationResult>();

            var     context = new LAContext();
            NSError authError;

            // Because LocalAuthentication APIs have been extended over time,
            // you must check iOS version before setting some properties
            context.LocalizedFallbackTitle = "Fallback";

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                context.LocalizedCancelTitle = "Cancel";
            }
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                context.LocalizedReason = "Authorize for access to secrets";
                BiometryType            = context.BiometryType == LABiometryType.TouchId ? "TouchID" : "FaceID";
                Console.WriteLine(BiometryType);
            }

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background
                    UIApplication.SharedApplication.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            System.Diagnostics.Debug.WriteLine("Authentication Success");
                            tcs.TrySetResult(new AuthenticationResult(true));
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Authentication Failure : " + error.Description);
                            tcs.TrySetResult(new AuthenticationResult(false, error.Description));
                        }
                    });
                });

                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, alertMessage ?? localizedReason, replyHandler);
            }

            else if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out authError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    //Make sure it runs on MainThread, not in Background
                    UIApplication.SharedApplication.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            System.Diagnostics.Debug.WriteLine("Authentication Success");
                            tcs.TrySetResult(new AuthenticationResult(true));
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Authentication Failure : " + error.Description);
                            tcs.TrySetResult(new AuthenticationResult(false, error.Description));
                        }
                    });
                });

                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, alertMessage ?? localizedReason, replyHandler);
            }
            else
            {
                //No Auth setup on Device
                Console.WriteLine($"This device doesn't have authentication configured: {authError.ToString()}");
                tcs.TrySetResult(new AuthenticationResult(false, "This device does't have authentication configured."));
            }

            return(tcs.Task);
        }
Example #37
0
        /// <summary>
        /// TouchId authentication test
        /// </summary>
        private void AuthenticateMe()
        {
            var context = new LAContext();
            NSError AuthError;
            var myReason = new NSString("Login to take a picture");

            if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
            {
                var replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    this.InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            Console.WriteLine("You logged in!");
                            _authenticateButton.Hidden = true;
                            Initialize();
                        }
                        else
                        {
                            // Inform the user authentication failed
                        }
                    });

                });
                context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
            };
        }
Example #38
0
 public void BiometricsLogin()
 {
     var context = new LAContext();
     NSError AuthError;
     var myReason = new NSString(LoginScreenData.BioLoginMessage);
     if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
     {
         var replyHandler = new LAContextReplyHandler((success, error) =>
         {
             this.InvokeOnMainThread(() =>
             {
                 if (success)
                 {
                     var obj = Global.DatabaseManager.GetUsername();
                     var pwd = Encrypt.DecryptString(obj.PWD);
                     Dictionary<string, string> parameters = new Dictionary<string, string>();
                     parameters.Add("username", obj.Username);
                     parameters.Add("password", pwd);
                     parameters.Add("app_device_number", Device.DeviceID);
                     loginScreenView.Hide();
                     initLoadingScreenView(LoginScreenData.LoadingScreenTextLogin);
                     atimer = new Timer(1000);
                     atimer.Elapsed += (s, e) =>
                     {
                         if (ServerURLReady)
                         {
                             InvokeOnMainThread(() =>
                             {
                                 LoginWebCall(parameters);
                                 atimer.Stop();
                                 atimer.Dispose();
                             });
                         }
                     };
                     atimer.AutoReset = true;
                     atimer.Enabled = true;
                 }
                 else if (error!=null && error.ToString().Contains("Application retry limit exceeded")){
                     //Show fallback mechanism here
                     new UIAlertView(LoginScreenData.AlertScreenBioLoginFailTitle,
                                     error.ToString()+" "+LoginScreenData.AlertScreenBioLoginFaildMessage,
                                     null, LoginScreenData.AlertScreenBioLoginFaildCancelBtnTitle, null).Show();
                 }
                 PWDLogin();
             });
         });
         context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, myReason, replyHandler);
     }
     else {
         loginScreenView.userNameTextField.Hidden = false;
         loginScreenView.passwordTextField.Hidden = false;
         loginScreenView.loginBtn.Hidden = false;
         loginScreenView.fingerPrintView.Hidden = true;
     }
 }