Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 15 additions & 10 deletions TouchID.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
Expand All @@ -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;

Expand All @@ -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
Expand All @@ -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
Expand Down