Determine if an iOS device supports TouchID without setting passcode

前端 未结 7 1713
一生所求
一生所求 2020-12-25 13:27

I\'m currently developing an iOS app that enables users to log in to the app using TouchID, but firstly they must set up a password inside the app first. Problem is, to show

相关标签:
7条回答
  • 2020-12-25 14:14

    For Objective C
    It works great on all devices without checking device version.

    - (void)canAuthenticatedByTouchID{
    LAContext *myContext = [[LAContext alloc] init];
    NSError *authError = nil;
    NSString *myLocalizedReasonString = touchIDRequestReason;
    
    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
     }else{
        switch (authError.code) {
            case kLAErrorTouchIDNotAvailable:
                [labelNotSupportTouchID setHidden:NO];
                [switchBtn setHidden:YES];
                [labelEnableTouchid setHidden:YES];
                static dispatch_once_t onceToken;
                dispatch_once(&onceToken, ^{
                    [self showAlertMessage:@"EyeCheck Pro" message:@"Device does not support Touch ID Service."];
                });
    
                break;
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题