似乎Face Id正在忽略localizedFallbackTitle
和localizedReason
。但是localizedCancelTitle
运行正常。有谁知道如何使它工作?
我的代码:
LAContext *context = [[LAContext alloc] init];
if ([context respondsToSelector:@selector(setLocalizedCancelTitle:)]) {
context.localizedCancelTitle = [Language get:CANCEL alter:nil];
}
if ([context respondsToSelector:@selector(setLocalizedFallbackTitle:)])
{
context.localizedFallbackTitle = [Language get:TRY_AGAIN alter:nil];
}
NSError *error = nil;
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthentication
localizedReason:[Language get:AUTHRNTICATE_USING_YOUR_FACE alter:nil] reply:^(BOOL success, NSError *error) {
//code
}
屏幕截图:
如果可能,我想将所有内容都本地化。
注意:随附的屏幕截图是在模拟器上拍摄的。我也检查过
它在实际设备上,但结果是相同的。另外,对于Touch ID,它可以正常工作。
最佳答案
根据此Post,在身份验证过程之间没有用于更改原因的API。
已本地化原因
应用提供的请求身份验证的原因,显示在向用户显示的身份验证对话框中。
您可以使用BiometricAuthentication显示您的消息。
BioMetricAuthenticator.authenticateWithBioMetrics(reason: "", success: {
// authentication successful
}, failure: { [weak self] (error) in
// do nothing on canceled
if error == .canceledByUser || error == .canceledBySystem {
return
}
// device does not support biometric (face id or touch id) authentication
else if error == .biometryNotAvailable {
self?.showErrorAlert(message: error.message())
}
// show alternatives on fallback button clicked
else if error == .fallback {
// here we're entering username and password
self?.txtUsername.becomeFirstResponder()
}
// No biometry enrolled in this device, ask user to register fingerprint or face
else if error == .biometryNotEnrolled {
self?.showGotoSettingsAlert(message: error.message())
}
// Biometry is locked out now, because there were too many failed attempts.
// Need to enter device passcode to unlock.
else if error == .biometryLockedout {
// show passcode authentication
}
// show error on authentication failed
else {
self?.showErrorAlert(message: error.message())
}
})
关于ios - 无法为不匹配的脸部定位“脸部ID”弹出窗口,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50940994/