Skip to content

Commit 8aa2785

Browse files
committed
Released SDK version 5.8.0
1 parent 050cc28 commit 8aa2785

File tree

12 files changed

+234
-10
lines changed

12 files changed

+234
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
5.8.0 Release notes (2023-04-20)
2+
=============================================================
3+
4+
### Enhancements
5+
* Added FaceID helper in the LoginRadius SDK for authentication through facial recognition.
6+
For detailed information on FaceID, please refer to the following document:
7+
https://developer.apple.com/documentation/localauthentication/logging_a_user_into_your_app_with_face_id_or_touch_id
8+
9+
110
5.7.0 Release notes (2022-12-27)
211
=============================================================
312

Example/ObjCDemo/ObjCDemo/ViewController.m

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "DetailViewController.h"
1212
#import "XLFormViewControllerExtension.h"
1313
#import "AppDelegate.h"
14+
#import <LocalAuthentication/LocalAuthentication.h>
1415

1516
@interface ViewController ()
1617
@property ( nonatomic, nullable) BOOL *isEmailAvailable;
@@ -210,11 +211,11 @@ - (void) setupForm
210211
//Social Login Section
211212
if(![[[LoginRadiusSDK sharedInstance] session] isLoggedIn])
212213
{
213-
section = [XLFormSectionDescriptor formSectionWithTitle:@"Touch ID"];
214+
section = [XLFormSectionDescriptor formSectionWithTitle:@"Touch / Face ID"];
214215
[form addFormSection:section];
215216

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);
218219
[section addFormRow:row];
219220
}
220221

@@ -573,14 +574,64 @@ - (void) showTouchIDLogin
573574
{
574575
[[LRTouchIDAuth sharedInstance] localAuthenticationWithFallbackTitle:@"" completion:^(BOOL success, NSError *error) {
575576
if (success) {
577+
[self showAlert:@"Success" message:@"Successfully Authenticated"];
576578
NSLog(@"successfully authenticated with touch id");
577579
[self showProfileController];
578580
} else {
581+
[self showAlert:@"Error" message:error.description];
579582
NSLog(@"Error: %@", [error description]);
580583
}
581584
}];
582585
}
583586

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+
584635
- (void) errorMessage:(NSDictionary *)data
585636
error: (NSError *) error{
586637

Example/SwiftDemo/SwiftDemo/ViewController.swift

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import LoginRadiusSDK
1010
import Eureka
1111
import SwiftyJSON
1212
import AuthenticationServices
13+
import LocalAuthentication
1314

1415
/* Google Native SignIn
1516
import GoogleSignIn
@@ -363,16 +364,16 @@ class ViewController: FormViewController
363364

364365
if !LoginRadiusSDK.sharedInstance().session.isLoggedIn
365366
{
366-
form +++ Section("Touch ID")
367+
form +++ Section("Touch / Face ID")
367368
{
368-
$0.tag = "Touch ID"
369+
$0.tag = "Touch / Face ID"
369370
}
370371

371-
<<< ButtonRow ("Touch ID")
372+
<<< ButtonRow ("Touch / Face ID")
372373
{
373374
$0.title = $0.tag
374375
}.onCellSelection{ row,arg in
375-
self.showTouchIDLogin()
376+
self.biometryType()
376377
}
377378
}
378379

@@ -852,6 +853,57 @@ class ViewController: FormViewController
852853
})
853854
}
854855

856+
func showFaceIDLogin()
857+
{
858+
LRFaceIDAuth.sharedInstance().localAuthentication(withFallbackTitle: " ", completion: {
859+
(success, error) in
860+
if let err = error{
861+
self.showAlert(title: "ERROR", message: err.localizedDescription)
862+
}else{
863+
self.showAlert(title: "SUCCESS", message:"Valid User")
864+
print("Face ID authentication successfull")
865+
self.showProfileController()
866+
}
867+
})
868+
}
869+
870+
871+
func biometryType()
872+
{
873+
874+
let context = LAContext()
875+
876+
var error: NSError?
877+
878+
if context.canEvaluatePolicy(
879+
LAPolicy.deviceOwnerAuthenticationWithBiometrics,
880+
error: &error) {
881+
if (error != nil) {
882+
print(error?.description)
883+
} else {
884+
885+
if #available(iOS 11.0.1, *) {
886+
if (context.biometryType == .faceID) {
887+
//localizedReason = "Unlock using Face ID"
888+
self.showFaceIDLogin()
889+
890+
print("Face ID supports")
891+
892+
} else if (context.biometryType == .touchID) {
893+
//localizedReason = "Unlock using Touch ID"
894+
self.showTouchIDLogin()
895+
print("TouchId support")
896+
897+
} else {
898+
//localizedReason = "Unlock using Application Passcode"
899+
print("No Biometric support")
900+
}
901+
902+
}
903+
}
904+
}
905+
906+
}
855907
func errorAlert(data:[AnyHashable:Any]?, error:Error )
856908
{
857909

LoginRadiusSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'LoginRadiusSDK'
4-
s.version = '5.7.0'
4+
s.version = '5.8.0'
55
s.summary = 'Official LoginRadius SDK for iOS to integrate User Registration Service or Social Login in your app.'
66

77
s.description = <<-DESC

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ target 'TargetName' do
4848
4949
#Comment the next line if you don't want to use dynamic frameworks
5050
use_frameworks!
51-
pod 'LoginRadiusSDK', '~> 5.7.0'
51+
pod 'LoginRadiusSDK', '~> 5.8.0'
5252
end
5353
5454
```

Sources/FaceID/LRFaceIDAuth.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// LRFaceIDAuth.h
3+
// Pods
4+
//
5+
// Created by Megha Agarwal on 15/12/22.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
#import "LoginRadiusSDK.h"
10+
11+
12+
13+
@interface LRFaceIDAuth : NSObject
14+
15+
#pragma mark - Init
16+
17+
/**
18+
* Initializer
19+
* @return singleton instance
20+
*/
21+
+ (instancetype)sharedInstance;
22+
23+
24+
25+
- (void)localAuthenticationWithFallbackTitle:(NSString *)localizedFallbackTitle
26+
completion:(LRServiceCompletionHandler)handler;
27+
28+
@end
29+
30+

Sources/FaceID/LRFaceIDAuth.m

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// LRFaceIDAuth.m
3+
// Pods
4+
//
5+
// Created by Megha Agarwal on 15/12/22.
6+
//
7+
8+
#import "LRFaceIDAuth.h"
9+
#import <LocalAuthentication/LocalAuthentication.h>
10+
#import "LRErrors.h"
11+
#import "LoginRadiusError.h"
12+
#import "LoginRadiusSDK.h"
13+
14+
@implementation LRFaceIDAuth
15+
16+
+ (instancetype)sharedInstance {
17+
static dispatch_once_t onceToken;
18+
static LRFaceIDAuth *instance;
19+
20+
dispatch_once(&onceToken, ^{
21+
instance = [[LRFaceIDAuth alloc] init];
22+
});
23+
24+
return instance;
25+
}
26+
27+
28+
- (void)localAuthenticationWithFallbackTitle:(NSString *)localizedFallbackTitle
29+
completion:(LRServiceCompletionHandler)handler{
30+
31+
LAContext *context = [[LAContext alloc] init];
32+
NSError *error = nil;
33+
34+
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
35+
// Authenticate User
36+
context.localizedFallbackTitle = localizedFallbackTitle;
37+
38+
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
39+
localizedReason:@"Use FaceID to Authenticate"
40+
reply:^(BOOL success, NSError *error) {
41+
42+
if (error) {
43+
handler(NO, error);
44+
}
45+
if (success) {
46+
handler(YES, nil);
47+
} else {
48+
handler(NO, [LRErrors faceIDNotDeviceOwner]);
49+
}
50+
}];
51+
52+
} else {
53+
NSError *error = [LRErrors faceIDNotAvailable];
54+
handler(NO, error);
55+
}
56+
}
57+
58+
@end

Sources/Helper/LRErrorCode.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ typedef NS_ENUM(NSInteger, LRErrorCode) {
104104
* TouchID error
105105
*/
106106
LRErrorCodeTouchIDNotAvailable,
107+
/**
108+
* User is not verified
109+
*/
110+
/**
111+
* FaceID error
112+
*/
113+
LRErrorCodeFaceIDNotAvailable,
107114
/**
108115
* User is not verified
109116
*/

Sources/Helper/LRErrors.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
+ (NSError*)touchIDNotAvailable;
4646
+ (NSError*)touchIDNotDeviceOwner;
4747

48-
48+
#pragma mark - Face ID
49+
+ (NSError*)faceIDNotAvailable;
50+
+ (NSError*)faceIDNotDeviceOwner;
4951

5052
@end

Sources/Helper/LRErrors.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,15 @@ + (NSError*)touchIDNotDeviceOwner {
150150
failureReason:@"TouchID Authentiction failed since the user is not the device's owner"];
151151
}
152152

153+
+ (NSError*)faceIDNotAvailable {
154+
return [NSError errorWithCode:LRErrorCodeFaceIDNotAvailable
155+
description:@"Face ID authentication failed"
156+
failureReason:@"The User's device cannot be authenticated using FaceID"];
157+
}
158+
159+
+ (NSError*)faceIDNotDeviceOwner {
160+
return [NSError errorWithCode:LRErrorCodeFaceIDNotAvailable
161+
description:@"Face ID authentication failed"
162+
failureReason:@"FaceID Authentiction failed since the user is not the device's owner"];
163+
}
153164
@end

0 commit comments

Comments
 (0)