Skip to content

Commit

Permalink
Released SDK version 5.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Giriraj1200 committed Apr 20, 2023
1 parent 050cc28 commit 8aa2785
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 10 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
5.8.0 Release notes (2023-04-20)
=============================================================

### Enhancements
* Added FaceID helper in the LoginRadius SDK for authentication through facial recognition.
For detailed information on FaceID, please refer to the following document:
https://developer.apple.com/documentation/localauthentication/logging_a_user_into_your_app_with_face_id_or_touch_id


5.7.0 Release notes (2022-12-27)
=============================================================

Expand Down
57 changes: 54 additions & 3 deletions Example/ObjCDemo/ObjCDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "DetailViewController.h"
#import "XLFormViewControllerExtension.h"
#import "AppDelegate.h"
#import <LocalAuthentication/LocalAuthentication.h>

@interface ViewController ()
@property ( nonatomic, nullable) BOOL *isEmailAvailable;
Expand Down Expand Up @@ -210,11 +211,11 @@ - (void) setupForm
//Social Login Section
if(![[[LoginRadiusSDK sharedInstance] session] isLoggedIn])
{
section = [XLFormSectionDescriptor formSectionWithTitle:@"Touch ID"];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Touch / Face ID"];
[form addFormSection:section];

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"TouchID" rowType:XLFormRowDescriptorTypeButton title:@"Touch ID"];
row.action.formSelector = @selector(showTouchIDLogin);
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Touch / Face ID" rowType:XLFormRowDescriptorTypeButton title:@"Touch / Face ID"];
row.action.formSelector = @selector(biometryType);
[section addFormRow:row];
}

Expand Down Expand Up @@ -573,14 +574,64 @@ - (void) showTouchIDLogin
{
[[LRTouchIDAuth sharedInstance] localAuthenticationWithFallbackTitle:@"" completion:^(BOOL success, NSError *error) {
if (success) {
[self showAlert:@"Success" message:@"Successfully Authenticated"];
NSLog(@"successfully authenticated with touch id");
[self showProfileController];
} else {
[self showAlert:@"Error" message:error.description];
NSLog(@"Error: %@", [error description]);
}
}];
}

- (void) showFaceIDLogin
{
[[LRFaceIDAuth sharedInstance]localAuthenticationWithFallbackTitle:@"" completion:^(BOOL success, NSError *error) {
if (success){
[self showAlert:@"Success" message:@"Successfully Authenticated"];
NSLog(@"Successfully authenticated with Face ID");
[self showProfileController];
}else{
[self showAlert:@"Error" message:error.description];
NSLog(@"Error: %@", [error description]);
}
}];
}

- (void) biometryType
{
LAContext *laContext = [[LAContext alloc] init];

NSError *error;

if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {

if (error != NULL) {
NSLog(error.description);
} else {

if (@available(iOS 11.0.1, *)) {
if (laContext.biometryType == LABiometryTypeFaceID) {
//localizedReason = "Unlock using Face ID"
[self showFaceIDLogin];
NSLog(@"FaceId support");

} else if (laContext.biometryType == LABiometryTypeTouchID) {
//localizedReason = "Unlock using Touch ID"
[self showTouchIDLogin];
NSLog(@"TouchId support");

} else {
//localizedReason = "Unlock using Application Passcode"
NSLog(@"No Biometric support");
}

}
}
}
}


- (void) errorMessage:(NSDictionary *)data
error: (NSError *) error{

Expand Down
60 changes: 56 additions & 4 deletions Example/SwiftDemo/SwiftDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import LoginRadiusSDK
import Eureka
import SwiftyJSON
import AuthenticationServices
import LocalAuthentication

/* Google Native SignIn
import GoogleSignIn
Expand Down Expand Up @@ -363,16 +364,16 @@ class ViewController: FormViewController

if !LoginRadiusSDK.sharedInstance().session.isLoggedIn
{
form +++ Section("Touch ID")
form +++ Section("Touch / Face ID")
{
$0.tag = "Touch ID"
$0.tag = "Touch / Face ID"
}

<<< ButtonRow ("Touch ID")
<<< ButtonRow ("Touch / Face ID")
{
$0.title = $0.tag
}.onCellSelection{ row,arg in
self.showTouchIDLogin()
self.biometryType()
}
}

Expand Down Expand Up @@ -852,6 +853,57 @@ class ViewController: FormViewController
})
}

func showFaceIDLogin()
{
LRFaceIDAuth.sharedInstance().localAuthentication(withFallbackTitle: " ", completion: {
(success, error) in
if let err = error{
self.showAlert(title: "ERROR", message: err.localizedDescription)
}else{
self.showAlert(title: "SUCCESS", message:"Valid User")
print("Face ID authentication successfull")
self.showProfileController()
}
})
}


func biometryType()
{

let context = LAContext()

var error: NSError?

if context.canEvaluatePolicy(
LAPolicy.deviceOwnerAuthenticationWithBiometrics,
error: &error) {
if (error != nil) {
print(error?.description)
} else {

if #available(iOS 11.0.1, *) {
if (context.biometryType == .faceID) {
//localizedReason = "Unlock using Face ID"
self.showFaceIDLogin()

print("Face ID supports")

} else if (context.biometryType == .touchID) {
//localizedReason = "Unlock using Touch ID"
self.showTouchIDLogin()
print("TouchId support")

} else {
//localizedReason = "Unlock using Application Passcode"
print("No Biometric support")
}

}
}
}

}
func errorAlert(data:[AnyHashable:Any]?, error:Error )
{

Expand Down
2 changes: 1 addition & 1 deletion LoginRadiusSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

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

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target 'TargetName' do
#Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'LoginRadiusSDK', '~> 5.7.0'
pod 'LoginRadiusSDK', '~> 5.8.0'
end
```
Expand Down
30 changes: 30 additions & 0 deletions Sources/FaceID/LRFaceIDAuth.h
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


58 changes: 58 additions & 0 deletions Sources/FaceID/LRFaceIDAuth.m
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
7 changes: 7 additions & 0 deletions Sources/Helper/LRErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ typedef NS_ENUM(NSInteger, LRErrorCode) {
* TouchID error
*/
LRErrorCodeTouchIDNotAvailable,
/**
* User is not verified
*/
/**
* FaceID error
*/
LRErrorCodeFaceIDNotAvailable,
/**
* User is not verified
*/
Expand Down
4 changes: 3 additions & 1 deletion Sources/Helper/LRErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
+ (NSError*)touchIDNotAvailable;
+ (NSError*)touchIDNotDeviceOwner;


#pragma mark - Face ID
+ (NSError*)faceIDNotAvailable;
+ (NSError*)faceIDNotDeviceOwner;

@end
11 changes: 11 additions & 0 deletions Sources/Helper/LRErrors.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@ + (NSError*)touchIDNotDeviceOwner {
failureReason:@"TouchID Authentiction failed since the user is not the device's owner"];
}

+ (NSError*)faceIDNotAvailable {
return [NSError errorWithCode:LRErrorCodeFaceIDNotAvailable
description:@"Face ID authentication failed"
failureReason:@"The User's device cannot be authenticated using FaceID"];
}

+ (NSError*)faceIDNotDeviceOwner {
return [NSError errorWithCode:LRErrorCodeFaceIDNotAvailable
description:@"Face ID authentication failed"
failureReason:@"FaceID Authentiction failed since the user is not the device's owner"];
}
@end
1 change: 1 addition & 0 deletions Sources/LoginRadius.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ FOUNDATION_EXPORT const unsigned char LoginRadiusSDKVersionString[];
#import <LoginRadiusSDK/LoginRadiusSDK.h>
#import <LoginRadiusSDK/LoginRadiusSocialLoginManager.h>
#import <LoginRadiusSDK/LRTouchIDAuth.h>
#import <LoginRadiusSDK/LRFaceIDAuth.h>
#import <LoginRadiusSDK/LoginRadiusREST.h>
#import <LoginRadiusSDK/LRErrorCode.h>
#import <LoginRadiusSDK/LRErrors.h>
Expand Down
3 changes: 3 additions & 0 deletions Sources/LoginRadiusSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import "LoginRadiusSDK.h"
#import "LoginRadiusSocialLoginManager.h"
#import "LRTouchIDAuth.h"
#import "LRFaceIDAuth.h"
#import "LRSession.h"
#import "LoginRadiusEncryptor.h"

Expand All @@ -26,6 +27,7 @@
@interface LoginRadiusSDK ()
@property (strong, nonatomic) LoginRadiusSocialLoginManager *socialLoginManager;
@property (strong, nonatomic) LRTouchIDAuth *touchIDManager;
@property (strong, nonatomic) LRFaceIDAuth *faceIDManager;
@end

@implementation LoginRadiusSDK
Expand Down Expand Up @@ -79,6 +81,7 @@ - (instancetype)init {
_session = [[LRSession alloc] init];
_socialLoginManager = [[LoginRadiusSocialLoginManager alloc] init];
_touchIDManager = [[LRTouchIDAuth alloc] init];
_faceIDManager = [[LRFaceIDAuth alloc] init];
_customHeaders = customHeaders;
_setEncryption = setEncryption;
}
Expand Down

0 comments on commit 8aa2785

Please sign in to comment.