Skip to content

Commit

Permalink
IOS-42
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassan Ismaeel committed Jun 8, 2021
1 parent c9d5e86 commit fa99b76
Show file tree
Hide file tree
Showing 14 changed files with 547 additions and 101 deletions.
12 changes: 6 additions & 6 deletions Example/VoiceIt2-IosSDK/VoiceItViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ @implementation VoiceItViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.API_KEY = @"API_KEY_HERE";
self.API_TOKEN = @"API_TOKEN_HERE";

self.API_KEY = @"KEY_HERE";
self.API_TOKEN = @"TOKEN_HERE";
self.TEST_USER_ID_ONE = @"USER_ID_HERE";
self.TEST_USER_ID_TWO = @"USER_ID_HERE";
self.TEST_USER_ID = self.TEST_USER_ID_ONE;
self.TEST_GROUP_ID = @"GROUP_ID_HERE";
self.TEST_PHRASE = @"never forget tomorrow is a new day";
self.TEST_CONTENT_LANGUAGE = @"en-US";

NSMutableDictionary * styles = [[NSMutableDictionary alloc] init];
[styles setObject:@"#FBC132" forKey:@"kThemeColor"];
[styles setObject:@"default" forKey:@"kIconStyle"];
Expand Down Expand Up @@ -154,10 +154,10 @@ -(void)showAlert:(NSString *) alertMessage {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Message"
message:alertMessage
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}
Expand Down
4 changes: 4 additions & 0 deletions VoiceIt2-IosSDK/Classes/Base.lproj/Prompts.strings
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@
"FACE_RIGHT" = "Please turn your face to the right and back";
"LIVENESS_SUCCESS" = "Challenge passed!";
"LIVENESS_TRY_AGAIN" = "Failed liveness! Please try again";

/* Error Handling */
"NETWORK_ERROR" = "Please make sure you are connected to the internet";
"CREDENTIAL_ERROR" = "Please make sure your userId and credentials are correct";
31 changes: 30 additions & 1 deletion VoiceIt2-IosSDK/Classes/FaceEnrollmentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ -(void)stopWritingToVideoFile {
}

-(void)startEnrollmentProcess {
//Check if User Id is correct
if (![Utilities checkUserId:self.userToEnrollUserId]){
NSString *response = @"{\"responseCode\":\"CREDENTIAL_ERROR\",\"message\":\"Please make sure your userId and credentials are correct\"}";
[self exitWithResponse:response];
return;
}

//Check if there is Internet Connection
if (![Utilities checkNetwork]){
NSString *response = @"{\"responseCode\":\"NETWORK_ERROR\",\"message\":\"Please make sure you are connected to the internet\"}";
[self exitWithResponse:response];
return;
}

[self.myVoiceIt deleteAllEnrollments:self.userToEnrollUserId callback:^(NSString * deleteEnrollmentsJSONResponse){
[self makeLabelFlyIn: [ResponseManager getMessage:@"GET_ENROLLED"]];
[self startDelayedRecording:2.0];
Expand Down Expand Up @@ -331,7 +345,7 @@ -(void)makeLabelFlyIn:(NSString *)message {
});
}

-(void)cancelClicked{
-(void) cancelClicked{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[self navigationController] dismissViewControllerAnimated:YES completion:^{
[[self myNavController] userEnrollmentsCancelled];
Expand All @@ -340,6 +354,21 @@ -(void)cancelClicked{
});
}

-(void) exitWithResponse:(NSString *) jsonResponse {
NSLog(@"%@", jsonResponse);
NSDictionary *jsonObj = [Utilities getJSONObject:jsonResponse];
NSString * responseCode = [jsonObj objectForKey:@"responseCode"];
dispatch_async(dispatch_get_main_queue(), ^{
[self.messageLabel setText: [ResponseManager getMessage: responseCode]];
[self.messageLabel setAdjustsFontSizeToFitWidth:YES];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[self navigationController] dismissViewControllerAnimated:YES completion:^{
[[self myNavController] userEnrollmentsCancelled];
}];
});
}

#pragma mark - Camera Delegate Methods

// Code to Capture Face Rectangle and other cool metadata stuff
Expand Down
1 change: 1 addition & 0 deletions VoiceIt2-IosSDK/Classes/FaceVerificationViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
@property int lookingIntoCamCounter;
@property int failCounter;
@property int failsAllowed;
@property int error;
@property int numberOfLivenessFailsAllowed;

#pragma mark - Developer Passed Options
Expand Down
28 changes: 28 additions & 0 deletions VoiceIt2-IosSDK/Classes/FaceVerificationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ - (void)notEnoughFaceEnrollments:(NSString *) jsonResponse {
});
}

- (void)exitWithResponse:(NSString *) jsonResponse {
NSLog(@"%@", jsonResponse);
NSDictionary *jsonObj = [Utilities getJSONObject:jsonResponse];
NSString * responseCode = [jsonObj objectForKey:@"responseCode"];
[self setMessage:[ResponseManager getMessage: responseCode]];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated: YES completion:^{
[self userVerificationFailed](0.0, jsonResponse);
}];
});
}


#pragma mark - Liveness Data

-(void) handleLivenessResponse: (NSString*)result{
Expand Down Expand Up @@ -572,6 +585,21 @@ -(void) startVerificationProcess{
if (!self.continueRunning) {
return;
}

//Check if User Id is correct
if (![Utilities checkUserId:self.userToVerifyUserId]){
NSString *response = @"{\"responseCode\":\"CREDENTIAL_ERROR\",\"message\":\"Please make sure your userId and credentials are correct\"}";
[self exitWithResponse:response];
return;
}

//Check if there is Internet Connection
if (![Utilities checkNetwork]){
NSString *response = @"{\"responseCode\":\"NETWORK_ERROR\",\"message\":\"Please make sure you are connected to the internet\"}";
[self exitWithResponse:response];
return;
}

[self.myVoiceIt getAllFaceEnrollments:_userToVerifyUserId callback:^(NSString * jsonResponse){
NSDictionary *jsonObj = [Utilities getJSONObject:jsonResponse];
NSString * responseCode = [jsonObj objectForKey:@"responseCode"];
Expand Down
64 changes: 64 additions & 0 deletions VoiceIt2-IosSDK/Classes/Reachability.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
*/

#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>


typedef enum : NSInteger {
NotReachable = 0,
ReachableViaWiFi,
ReachableViaWWAN
} NetworkStatus;

#pragma mark IPv6 Support
//Reachability fully support IPv6. For full details, see ReadMe.md.


extern NSString *kReachabilityChangedNotification;


@interface Reachability : NSObject

/*!
* Use to check the reachability of a given host name.
*/
+ (instancetype)reachabilityWithHostName:(NSString *)hostName;

/*!
* Use to check the reachability of a given IP address.
*/
+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;

/*!
* Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
*/
+ (instancetype)reachabilityForInternetConnection;


#pragma mark reachabilityForLocalWiFi
//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information.
//+ (instancetype)reachabilityForLocalWiFi;

/*!
* Start listening for reachability notifications on the current run loop.
*/
- (BOOL)startNotifier;
- (void)stopNotifier;

- (NetworkStatus)currentReachabilityStatus;

/*!
* WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
*/
- (BOOL)connectionRequired;

@end


0 comments on commit fa99b76

Please sign in to comment.