public static async System.Threading.Tasks.Task Authenticate(DialogConfiguration dialogConfiguration) { _context = new LAContext(); _context.InvokeOnMainThread(async() => { var result = await _context.EvaluatePolicyAsync(LAPolicy.DeviceOwnerAuthentication, Configuration.DefaultFailAttemptNumberExceededMsg); bool success = result.Item1; NSError error = result.Item2; if (success) { dialogConfiguration.SuccessAction?.Invoke(); } else { if (error.Code == -2) { //user cancel return; } else if (error.Code == -1) { //too many failed attempt dialogConfiguration.FailedAction?.Invoke(); } } }); //NSError AuthError; //if (_context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)) //{ // Tuple<bool, NSError> result = await _context.EvaluatePolicyAsync(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, dialogConfiguration.DialogDescription); // bool success = result.Item1; // NSError error = result.Item2; // if (result.Item1 == true) // dialogConfiguration.SuccessAction?.Invoke(); // else // { // if (error.Code == -2) // { // //User cancel // return; // }else if(error.Code == -1) // { // } // //if (error.LocalizedDescription == "Fallback authentication mechanism selected.") // //{ // // var s = error.Code; // // result = await _context.EvaluatePolicyAsync(LAPolicy.DeviceOwnerAuthentication, descrptionMessage); // // if (result.Item1) // // successAction?.Invoke(); // //} // } //} //else //{ // _context.InvokeOnMainThread(async () => // { // var result = await _context.EvaluatePolicyAsync(LAPolicy.DeviceOwnerAuthentication, Configuration.DefaultFailAttemptNumberExceededMsg); // if (result.Item1) // dialogConfiguration.SuccessAction?.Invoke(); // }); //} }