ios - 无法为不匹配的人脸定位 Face Id 弹出窗口

标签 ios objective-c face-id

似乎 Face Id 忽略了 localizedFallbackTitlelocalizedReason。但是 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
}

截图:

Nonmatching face popup

如果可能,我想本地化此弹出窗口中的所有内容。

注意:附件截图是在模拟器上截取的。我也检查过 它在真实设备上,但结果是一样的。此外,对于 Touch id,它工作正常。

最佳答案

根据这个Post ,没有用于更改身份验证过程之间的原因的 API。

localizedReason

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

您可以使用 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 - 无法为不匹配的人脸定位 Face Id 弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50940994/

相关文章:

ios - 在没有 segue 的 View Controller 之间传递数据

ios - 通过平滑的推送过渡和没有导航 Controller 来更改 View Controller

objective-c - 在 .h 文件中使用静态 NSString?

ios - UIPopoverPresentationController 在 iPhone 上显示全屏模式

ios - 一次关闭两个 UIViewController 而不使用动画

ios - 定位服务 : 'Blue Bar' during 'Always' Mode

ios - 更改框架的目标名称或产品名称时找不到伞头

ios - 按钮和标签在segue后消失

ios - 模拟器不支持LAContext评估访问控制吗?

ios - Touch ID 和 Face ID 的官方图标