Skip to content

Commit

Permalink
Remove LAPolicy in tvOS target (oblador#393)
Browse files Browse the repository at this point in the history
* [tvOS] remove LAPolicy to fix build

Co-authored-by: @gaborkajtar

* Fix semi
  • Loading branch information
Krisztiaan authored Oct 26, 2020
1 parent 98926e4 commit 53f3a3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions RNKeychainManager/RNKeychainManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#import <React/RCTBridge.h>
#import <React/RCTUtils.h>

#if TARGET_OS_IOS
#import <LocalAuthentication/LAContext.h>
#endif
#import <UIKit/UIKit.h>

@implementation RNKeychainManager
Expand Down Expand Up @@ -152,6 +154,7 @@ CFStringRef accessibleValue(NSDictionary *options)
#define kBiometryTypeTouchID @"TouchID"
#define kBiometryTypeFaceID @"FaceID"

#if TARGET_OS_IOS
LAPolicy authPolicy(NSDictionary *options)
{
if (options && options[kAuthenticationType]) {
Expand All @@ -161,6 +164,7 @@ LAPolicy authPolicy(NSDictionary *options)
}
return LAPolicyDeviceOwnerAuthentication;
}
#endif

SecAccessControlCreateFlags accessControlValue(NSDictionary *options)
{
Expand Down Expand Up @@ -203,10 +207,12 @@ - (void)insertKeychainEntry:(NSDictionary *)attributes

if (accessControl) {
NSError *aerr = nil;
#if TARGET_OS_IOS
BOOL canAuthenticate = [[LAContext new] canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&aerr];
if (aerr || !canAuthenticate) {
return rejectWithError(reject, aerr);
}
#endif

CFErrorRef error = NULL;
SecAccessControlRef sacRef = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
Expand Down

0 comments on commit 53f3a3a

Please sign in to comment.