Is there any way to check my application is enable with TouchID,
How can i check if my application is enable with TouchID,
For example :
DropBox have capability to enable figure print sensor enable. now is there any method to check if my application showing TouchID screen based on touchid enable.
According you use Objective-C
First, add method to check iOS Version
TouchID
needs iOS8+ to work
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
Then, use LAContext
canEvaluatePolicy:error:
to evaluate if TouchID
exist
Preflights an authentication policy to see if it is possible for authentication to succeed
- (BOOL)isTouchIDAvailable {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
return [[[LAContext alloc] init] canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];
}
return NO;
}
You do not want to check the iOS version, sure, it might work but it is a bad practice. Check for the feature instead. See if LAContext is available.
if ([LAContext class]) {
// touch ID is available for the device
// call canEvaluatePolicy:error to see if the user has set a fingerprint.
}
assuming ios 8+ deployment target
var authError : NSError?
if LAContext().canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {
// do your thing dependent on touch id being useable on the device
}
in case you still need to support ios7 do the extra hoop
if NSClassFromString("LAContext") != nil && LAContext().canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {