gpt4 book ai didi

密码错误的 iOS 超时

转载 作者:行者123 更新时间:2023-11-29 01:17:55 25 4
gpt4 key购买 nike

在我正在开发的应用程序中,我让用户使用密码作为 TouchID 的备份。显然,出于安全原因,该密码应该具有某种形式的“超时”,类似于 iPhone 锁屏。

实现这一目标的最佳方法是什么?

我最初的想法是保存用户最后一次错误的尝试,并检查其是否比当前日期早 x 分钟。

我认为这在实践中是可行的,但是将其与系统时钟绑定(bind)绝对不是最安全的方法。

任何有关此事的帮助将不胜感激。

最佳答案

我已经在多个应用程序中实现了某种形式的此功能。我通常做的是使用一个计时器,该计时器在用户与应用程序交互时开始(如果存在的话,还会取消前一个计时器)。当时间用完时,将运行超时方法。
像这样的东西:

- (void)pressedButton:(UIButton *)button {
// record button press

[self scheduleInteractionTimer];
}

- (void)scheduleInteractionTimer {
if (_timeoutTimer) {
[_timeoutTimer invalidate];
}
_timeoutTimer = [NSTimer timerWithTimeInterval:timeoutTime target:self selector:@selector(timeoutTripped) userInfo:nil repeats:NO];
_timeoutTimer.tolerance = 5.0; // optional
[[NSRunLoop mainRunLoop] addTimer:_timeoutTimer forMode:NSRunLoopCommonModes];
}

- (void)timeoutTripped {
// whatever should be done for a timeout...
}

您绝对可以将 -scheduleInteractionTimer 与不正确的响应或您想要的任何其他内容相关联。

编辑:我还建议在应用进入后台时关闭密码 View 。

干杯

安东尼

关于密码错误的 iOS 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34937644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com