c# - iOS - 本地身份验证更改失败消息

标签 c# ios objective-c xamarin touch-id

我的应用程序中有一项 LA 服务几乎像往常一样使用 TouchID。问题是我想更改提示 touchId 身份验证时显示的警报中的内容。首先它显示我在原因字符串中声明的内容,如果身份验证失败,它只会将标题更改为“重复”,但正文保持不变。

当身份验证失败时,是否有机会为不同的消息更改警报正文?我尝试更改原因字符串但没有效果。

此项目是使用 Xamarin 创建的,但也可以使用 Objective-C/Swift 代码。提前致谢!

UPD:这是我的代码:

if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out authError))
            {
                var myReason = new NSString("Use your finger to authenticate");

                replyHandler = new LAContextReplyHandler((success, error) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        if (success)
                        {
                            Login();
                        }
                        else
                        {
                            myReason = new NSString("Nope try again");

                            switch ((long)error.Code)
                            {
                                case (long)LAStatus.TouchIDLockout: // 5 times wrong, TouchID is locked system-wide
                                    {
                                        var alert = new UIAlertView("Sorry", "Exceeded and blocked message", null, "OK");
                                        alert.Show();
                                        touchIdButton.Hidden = true;
                                    }
                                    break;
                                case (long)LAStatus.AuthenticationFailed: // 3 times wrong
                                    {
                                        var alert = new UIAlertView("Sorry", "Exceeded message", null, "OK");
                                        alert.Show();
                                        touchIdButton.Hidden = true;
                                    }
                                    break;
                                case (long)LAStatus.UserFallback: //Enter Passcode
                                    //no UserFallback for now
                                    break;
                            }

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

最佳答案

没有。没有用于在身份验证过程之间更改 Reason 的 API。

参见 https://developer.apple.com/documentation/localauthentication/lacontext/1514176-evaluatepolicy

localizedReason

The app-provided reason for requesting authentication, which displays in the authentication dialog presented to the user.

这意味着:您正在尝试的不是 Apple 的意图。请求授权的原因与失败的尝试次数无关。换句话说:您请求的原因在第一次尝试失败后没有改变。


广告版 block

如果您对指纹验证的跨平台解决方案感兴趣,请查看我的插件:) https://github.com/smstuebe/xamarin-fingerprint

关于c# - iOS - 本地身份验证更改失败消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48564925/

相关文章:

ios - 如何在afnetworking中的AFHTTPRequestOperationManager请求中获得返回

C#:使用 Silverlight FJCore 库以 12 位精度解码 JPEG 图像?

iphone - 如何将对象移动到排列?

c# - 如何在 Xamarin iOS 中创建垂直 ScrollView

ios - 我解开可选值,但在解开可选值时仍然意外发现 nil

ios - 如何在NSMutableDictionary中比较NSArray的元素?

ios - iOS 6.1 状态栏字体变化

c# - MemoryStream - 无法访问已关闭的流

c# - 如何使用 CSI.exe 脚本参数

c# - 字典允许我插入重复的键