iOS - 本地身份验证更改失败消息
iOS - Local authentication change fail message
我的应用程序中有一项 LA 服务几乎像往常一样使用 TouchID。问题是我想更改提示 touchId 身份验证时显示的警报中的内容。首先它显示我在原因字符串中声明的内容,如果身份验证失败,它只会将标题更改为 'Repeat',但 body 保持不变。
当验证失败时,是否有机会为不同的消息更改警报的 body?我尝试更改原因字符串但没有效果。
此项目是使用 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);
没有。没有 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 的意图。请求授权的原因与失败的尝试次数无关。换句话说:您请求的原因在第一次尝试失败后没有改变。
广告栏
如果您对指纹验证的跨平台解决方案感兴趣,请查看我的插件 :) https://github.com/smstuebe/xamarin-fingerprint
我的应用程序中有一项 LA 服务几乎像往常一样使用 TouchID。问题是我想更改提示 touchId 身份验证时显示的警报中的内容。首先它显示我在原因字符串中声明的内容,如果身份验证失败,它只会将标题更改为 'Repeat',但 body 保持不变。
当验证失败时,是否有机会为不同的消息更改警报的 body?我尝试更改原因字符串但没有效果。
此项目是使用 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);
没有。没有 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 的意图。请求授权的原因与失败的尝试次数无关。换句话说:您请求的原因在第一次尝试失败后没有改变。
广告栏
如果您对指纹验证的跨平台解决方案感兴趣,请查看我的插件 :) https://github.com/smstuebe/xamarin-fingerprint