diff --git a/README.md b/README.md index 568f60af..97de6bac 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,11 @@ iOS and Android differ slightly in their TouchID authentication. On Android you can customize the title and color of the pop-up by passing in the **optional config object** with a color and title key to the `authenticate` method. Even if you pass in the config object, iOS **does not** allow you change the color nor the title of the pop-up. iOS does support `passcodeFallback` as an option, which when set to `true` will allow users to use their device pin - useful for people with Face / Touch ID disabled. Passcode fallback only happens if the device does not have touch id or face id enabled. +### passcodeFallback will be enabled after face ID fails ( only in iOS ) + +Now, I have added the `passcodeFallback` after the face ID fails. So if user fail to login via faceID or Touch ID than it will give +one option for enter passcode. previoously it was giving error but now it is working. so user can enter the device PIN and it will give the success response + Error handling is also different between the platforms, with iOS currently providing much more descriptive error codes. ### App Permissions diff --git a/TouchID.m b/TouchID.m index 6bae6c9f..60f3d86d 100644 --- a/TouchID.m +++ b/TouchID.m @@ -13,16 +13,19 @@ @implementation TouchID NSError *error; // Check to see if we have a passcode fallback - NSNumber *passcodeFallback = [NSNumber numberWithBool:true]; + // NSNumber *passcodeFallback = [NSNumber numberWithBool:true]; + Boolean passcodeFallback = false; + if (RCTNilIfNull([options objectForKey:@"passcodeFallback"]) != nil) { - passcodeFallback = [RCTConvert NSNumber:options[@"passcodeFallback"]]; + // passcodeFallback = [RCTConvert NSNumber:options[@"passcodeFallback"]]; + passcodeFallback = [[RCTConvert NSNumber:options[@"passcodeFallback"]] boolValue]; } - if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { - + //Added condition to check when only touchID + if (!passcodeFallback && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { // No error found, proceed callback(@[[NSNull null], [self getBiometryType:context]]); - } else if ([passcodeFallback boolValue] && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) { + }else if (passcodeFallback && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) { // removed the conversion to boolValue // No error callback(@[[NSNull null], [self getBiometryType:context]]); @@ -46,7 +49,8 @@ @implementation TouchID options:(NSDictionary *)options callback: (RCTResponseSenderBlock)callback) { - NSNumber *passcodeFallback = [NSNumber numberWithBool:false]; + //NSNumber *passcodeFallback = [NSNumber numberWithBool:false]; + Boolean passcodeFallback = false; LAContext *context = [[LAContext alloc] init]; NSError *error; @@ -56,11 +60,12 @@ @implementation TouchID } if (RCTNilIfNull([options objectForKey:@"passcodeFallback"]) != nil) { - passcodeFallback = [RCTConvert NSNumber:options[@"passcodeFallback"]]; + //passcodeFallback = [RCTConvert NSNumber:options[@"passcodeFallback"]]; + passcodeFallback = [[RCTConvert NSNumber:options[@"passcodeFallback"]] boolValue]; } // Device has TouchID - if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { + if (!passcodeFallback && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { // Attempt Authentification [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason @@ -69,8 +74,8 @@ @implementation TouchID [self handleAttemptToUseDeviceIDWithSuccess:success error:error callback:callback]; }]; - // Device does not support TouchID but user wishes to use passcode fallback - } else if ([passcodeFallback boolValue] && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) { + // Device does support TouchID but user wishes to use passcode fallback + } else if (passcodeFallback && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) { // Attempt Authentification [context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:reason