-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
050cc28
commit 8aa2785
Showing
12 changed files
with
234 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// LRFaceIDAuth.h | ||
// Pods | ||
// | ||
// Created by Megha Agarwal on 15/12/22. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "LoginRadiusSDK.h" | ||
|
||
|
||
|
||
@interface LRFaceIDAuth : NSObject | ||
|
||
#pragma mark - Init | ||
|
||
/** | ||
* Initializer | ||
* @return singleton instance | ||
*/ | ||
+ (instancetype)sharedInstance; | ||
|
||
|
||
|
||
- (void)localAuthenticationWithFallbackTitle:(NSString *)localizedFallbackTitle | ||
completion:(LRServiceCompletionHandler)handler; | ||
|
||
@end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// LRFaceIDAuth.m | ||
// Pods | ||
// | ||
// Created by Megha Agarwal on 15/12/22. | ||
// | ||
|
||
#import "LRFaceIDAuth.h" | ||
#import <LocalAuthentication/LocalAuthentication.h> | ||
#import "LRErrors.h" | ||
#import "LoginRadiusError.h" | ||
#import "LoginRadiusSDK.h" | ||
|
||
@implementation LRFaceIDAuth | ||
|
||
+ (instancetype)sharedInstance { | ||
static dispatch_once_t onceToken; | ||
static LRFaceIDAuth *instance; | ||
|
||
dispatch_once(&onceToken, ^{ | ||
instance = [[LRFaceIDAuth alloc] init]; | ||
}); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
- (void)localAuthenticationWithFallbackTitle:(NSString *)localizedFallbackTitle | ||
completion:(LRServiceCompletionHandler)handler{ | ||
|
||
LAContext *context = [[LAContext alloc] init]; | ||
NSError *error = nil; | ||
|
||
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { | ||
// Authenticate User | ||
context.localizedFallbackTitle = localizedFallbackTitle; | ||
|
||
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics | ||
localizedReason:@"Use FaceID to Authenticate" | ||
reply:^(BOOL success, NSError *error) { | ||
|
||
if (error) { | ||
handler(NO, error); | ||
} | ||
if (success) { | ||
handler(YES, nil); | ||
} else { | ||
handler(NO, [LRErrors faceIDNotDeviceOwner]); | ||
} | ||
}]; | ||
|
||
} else { | ||
NSError *error = [LRErrors faceIDNotAvailable]; | ||
handler(NO, error); | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters