2016-03-05 35 views
2


取消LAContext評價目標C

我試着寫在目標下iphone代碼,基本上我試圖使用觸摸ID傳感器與LAContext類。我發送「使用生物識別技術進行身份驗證」請求,經過一段時間(例如200毫秒)後,我想取消該請求。不幸的是,我無法在我的代碼中取消這個請求,我發現的唯一方法是取消用戶請求並需要用戶操作。 這裏是我的代碼:

LAContext *context = [[LAContext alloc] init]; 
NSError *error = nil; 
if (true) { 
    [context 
evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics 
         localizedReason:@"Place your finger?" 
         reply:^(BOOL success, NSError *error) { 
         }]; 

我真的很感激,如果你們能幫助我。
謝謝。

回答

0

您可以實現自iOS 9以來。CAContext類中有一個invalidate方法。

在你的控制,僅編寫之後[context evaluatePolicy: localizedReason: reply:]

[self performSelector:@selector(invalidateCA) withObject:self afterDelay:0.2]; 

下面的代碼然後宣佈你的方法取消TouchID

- (void)invalidateCA 
{ 
    // you have to get a reference to it when you create CAContext 
    [self.context invalidate]; 
}