为什么我不能关闭Touch ID提示?

问题描述 投票:0回答:1

我已经创建了一个登录屏幕,并希望允许用户使用生物识别技术进行身份验证。我可以显示TouchID / FaceID对话框,但是无法使用“取消”按钮将其关闭。它会暂时消失,然后重新出现。有没有一种直接的方法来找出造成这种情况的原因。非常感谢。

更新:检查错误后,我在日志中收到以下内容:

Domain = com.apple.LocalAuthentication Code = -4“由另一个身份验证。“

代码:

@interface LoginViewController ()
@property (nonatomic, strong) LAContext *context;

@end

@implementation LoginViewController

- (LAContext *)context {
    if (_context == nil) {
        _context = [LAContext new];
    }
    return _context;
}
- (void)viewDidLoad {
    [super viewDidLoad];

    NSError *error;

    BOOL canAuthentication = [self.context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error];

    if (canAuthentication) {


        [self.context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@"FaceID" reply:^(BOOL success, NSError * _Nullable error) {
            if (success) {
                UIAlertController *alearC = [UIAlertController alertControllerWithTitle:@"Success" message:nil preferredStyle:UIAlertControllerStyleAlert];
                [alearC addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                }]];
                [self presentViewController:alearC animated:YES completion:nil];

            } else {
                NSLog(@"error%@",error);
            }
        }];
    }
}
objective-c touch-id
1个回答
0
投票

其原因通常是因为指纹扫描仪仍被先前的操作占用g。似乎您没有使用过cancellationSignal.cancel,或者好像没有使用过它。每次使用完扫描仪后,您都必须使用cancellationSignal.cancel发送信号,以表明扫描仪已完成其工作。

例如,如果任务失败,则看起来像这样,

text_state.setText(context.getString(R.string.fingerFailure));
cancellationSignal.cancel();

尝试在此上方或下方添加cancellationSignal.cancel()

[self presentViewController:alearC animated:YES completion:nil];

以及如果需要,在else块中也是如此。

让我知道是否可以解决您的问题,否则我会调查

© www.soinside.com 2019 - 2024. All rights reserved.