如何使用LAContext的touchIDAuthenticationAllowableReuseDuration属性?

时间:2016-02-18 07:01:22

标签: ios objective-c

LAContext.h中的

/// @discussion可以使用以秒为单位的时间间隔设置此属性。如果设备在此时间间隔内通过Touch ID成功解锁,则此上下文中的Touch ID身份验证将自动成功,并且将在不提示用户输入Touch ID的情况下调用回复块。默认值为0,表示之前没有TouchID身份验证可以重复使用。最大支持间隔为5分钟,将值设置超过5分钟不会增加可接受的间隔。

@property (nonatomic) NSTimeInterval touchIDAuthenticationAllowableReuseDuration NS_AVAILABLE_IOS(9_0);

但是当我使用此属性时没有效果

pragma mark - 生命周期

-

 (void)viewDidLoad {
    [super viewDidLoad];

    self.transitioningDelegate = self;
    self.modalPresentationStyle = UIModalPresentationCustom;

    self.context.touchIDAuthenticationAllowableReuseDuration = 5;

    [self authenticationWithtouchID];


    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self authenticationWithtouchID];
    });
}

15秒后,Ther上下文的TouchID静态身份验证可以是可用的

什么错了????

1 个答案:

答案 0 :(得分:0)

时间间隔设置为秒

您输入的值可能是非常短的持续时间。

尝试将间隔约为300分钟,持续5分钟/ 240分钟,持续4分钟

self.context.touchIDAuthenticationAllowableReuseDuration = 240;