|
11 | 11 | #import "DetailViewController.h" |
12 | 12 | #import "XLFormViewControllerExtension.h" |
13 | 13 | #import "AppDelegate.h" |
| 14 | +#import <LocalAuthentication/LocalAuthentication.h> |
14 | 15 |
|
15 | 16 | @interface ViewController () |
16 | 17 | @property ( nonatomic, nullable) BOOL *isEmailAvailable; |
@@ -210,11 +211,11 @@ - (void) setupForm |
210 | 211 | //Social Login Section |
211 | 212 | if(![[[LoginRadiusSDK sharedInstance] session] isLoggedIn]) |
212 | 213 | { |
213 | | - section = [XLFormSectionDescriptor formSectionWithTitle:@"Touch ID"]; |
| 214 | + section = [XLFormSectionDescriptor formSectionWithTitle:@"Touch / Face ID"]; |
214 | 215 | [form addFormSection:section]; |
215 | 216 |
|
216 | | - row = [XLFormRowDescriptor formRowDescriptorWithTag:@"TouchID" rowType:XLFormRowDescriptorTypeButton title:@"Touch ID"]; |
217 | | - row.action.formSelector = @selector(showTouchIDLogin); |
| 217 | + row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Touch / Face ID" rowType:XLFormRowDescriptorTypeButton title:@"Touch / Face ID"]; |
| 218 | + row.action.formSelector = @selector(biometryType); |
218 | 219 | [section addFormRow:row]; |
219 | 220 | } |
220 | 221 |
|
@@ -573,14 +574,64 @@ - (void) showTouchIDLogin |
573 | 574 | { |
574 | 575 | [[LRTouchIDAuth sharedInstance] localAuthenticationWithFallbackTitle:@"" completion:^(BOOL success, NSError *error) { |
575 | 576 | if (success) { |
| 577 | + [self showAlert:@"Success" message:@"Successfully Authenticated"]; |
576 | 578 | NSLog(@"successfully authenticated with touch id"); |
577 | 579 | [self showProfileController]; |
578 | 580 | } else { |
| 581 | + [self showAlert:@"Error" message:error.description]; |
579 | 582 | NSLog(@"Error: %@", [error description]); |
580 | 583 | } |
581 | 584 | }]; |
582 | 585 | } |
583 | 586 |
|
| 587 | +- (void) showFaceIDLogin |
| 588 | +{ |
| 589 | + [[LRFaceIDAuth sharedInstance]localAuthenticationWithFallbackTitle:@"" completion:^(BOOL success, NSError *error) { |
| 590 | + if (success){ |
| 591 | + [self showAlert:@"Success" message:@"Successfully Authenticated"]; |
| 592 | + NSLog(@"Successfully authenticated with Face ID"); |
| 593 | + [self showProfileController]; |
| 594 | + }else{ |
| 595 | + [self showAlert:@"Error" message:error.description]; |
| 596 | + NSLog(@"Error: %@", [error description]); |
| 597 | + } |
| 598 | + }]; |
| 599 | +} |
| 600 | + |
| 601 | +- (void) biometryType |
| 602 | +{ |
| 603 | + LAContext *laContext = [[LAContext alloc] init]; |
| 604 | + |
| 605 | + NSError *error; |
| 606 | + |
| 607 | + if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) { |
| 608 | + |
| 609 | + if (error != NULL) { |
| 610 | + NSLog(error.description); |
| 611 | + } else { |
| 612 | + |
| 613 | + if (@available(iOS 11.0.1, *)) { |
| 614 | + if (laContext.biometryType == LABiometryTypeFaceID) { |
| 615 | + //localizedReason = "Unlock using Face ID" |
| 616 | + [self showFaceIDLogin]; |
| 617 | + NSLog(@"FaceId support"); |
| 618 | + |
| 619 | + } else if (laContext.biometryType == LABiometryTypeTouchID) { |
| 620 | + //localizedReason = "Unlock using Touch ID" |
| 621 | + [self showTouchIDLogin]; |
| 622 | + NSLog(@"TouchId support"); |
| 623 | + |
| 624 | + } else { |
| 625 | + //localizedReason = "Unlock using Application Passcode" |
| 626 | + NSLog(@"No Biometric support"); |
| 627 | + } |
| 628 | + |
| 629 | + } |
| 630 | + } |
| 631 | + } |
| 632 | +} |
| 633 | + |
| 634 | + |
584 | 635 | - (void) errorMessage:(NSDictionary *)data |
585 | 636 | error: (NSError *) error{ |
586 | 637 |
|
|
0 commit comments