Open kristof01 opened 6 years ago
Yes, I'm facing the same issue isAvailable() returns null of the biometryType.
Same here, even when I try with promises or observables.
isAvailable() and save() both return null.
You can see in the source that this functionality is only implemented in later version (3.3.0), but this is not installed by default. Npm installs 3.2.1. The readme has instructions for installing the latest straight from repository.
@sjhoeksma Can you make a new release including this functionality? I would be very grateful.
@sjhoeksma +1, forking for now I guess 😞
any updates on this ? I am also getting null in the iOS
Hey @gopi014 override isAvailable function in TouchID.m with this one
- (void) isAvailable:(CDVInvokedUrlCommand*)command {
LAContext *context = [[LAContext alloc] init];
if (NSClassFromString(@"LAContext") == NULL) {
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR] callbackId:command.callbackId];
return;
}
[self.commandDelegate runInBackground:^{
NSError *error = nil;
LAContext *laContext = [[LAContext alloc] init];
if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
NSString *biometryType = @"touch";
if (@available(iOS 11.0, *)) {
if (laContext.biometryType == LABiometryTypeFaceID) {
biometryType = @"face";
}
}
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:biometryType]
callbackId:command.callbackId];
} else {
NSArray *errorKeys = @[@"code", @"localizedDescription"];
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[error dictionaryWithValuesForKeys:errorKeys]]
callbackId:command.callbackId];
}
}];
}
Thanks for your reply. It is working fine now.
Any news on this one? Still getting null with the official release.
Hey @gopi014 override isAvailable function in TouchID.m with this one
- (void) isAvailable:(CDVInvokedUrlCommand*)command { LAContext *context = [[LAContext alloc] init]; if (NSClassFromString(@"LAContext") == NULL) { [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR] callbackId:command.callbackId]; return; } [self.commandDelegate runInBackground:^{ NSError *error = nil; LAContext *laContext = [[LAContext alloc] init]; if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { NSString *biometryType = @"touch"; if (@available(iOS 11.0, *)) { if (laContext.biometryType == LABiometryTypeFaceID) { biometryType = @"face"; } } [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:biometryType] callbackId:command.callbackId]; } else { NSArray *errorKeys = @[@"code", @"localizedDescription"]; [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[error dictionaryWithValuesForKeys:errorKeys]] callbackId:command.callbackId]; } }]; }
Work for me. Thanks
@sjhoeksma please include this code to your repo 🙏! don't wan't to fork.
Hey @gopi014 override isAvailable function in TouchID.m with this one
- (void) isAvailable:(CDVInvokedUrlCommand*)command { LAContext *context = [[LAContext alloc] init]; if (NSClassFromString(@"LAContext") == NULL) { [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR] callbackId:command.callbackId]; return; } [self.commandDelegate runInBackground:^{ NSError *error = nil; LAContext *laContext = [[LAContext alloc] init]; if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { NSString *biometryType = @"touch"; if (@available(iOS 11.0, *)) { if (laContext.biometryType == LABiometryTypeFaceID) { biometryType = @"face"; } } [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:biometryType] callbackId:command.callbackId]; } else { NSArray *errorKeys = @[@"code", @"localizedDescription"]; [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[error dictionaryWithValuesForKeys:errorKeys]] callbackId:command.callbackId]; } }]; }
Hey @gopi014 override isAvailable function in TouchID.m with this one
- (void) isAvailable:(CDVInvokedUrlCommand*)command { LAContext *context = [[LAContext alloc] init]; if (NSClassFromString(@"LAContext") == NULL) { [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR] callbackId:command.callbackId]; return; } [self.commandDelegate runInBackground:^{ NSError *error = nil; LAContext *laContext = [[LAContext alloc] init]; if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { NSString *biometryType = @"touch"; if (@available(iOS 11.0, *)) { if (laContext.biometryType == LABiometryTypeFaceID) { biometryType = @"face"; } } [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:biometryType] callbackId:command.callbackId]; } else { NSArray *errorKeys = @[@"code", @"localizedDescription"]; [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[error dictionaryWithValuesForKeys:errorKeys]] callbackId:command.callbackId]; } }]; }
How about android? Does it returns biometry type on android? or we should add some code also?
The success callback of isAvailable() returns null instead of the biometryType. Is it possible that this functionality is currently broken? I'm working with version 3.2.1 in IONIC 3.