iOS Native Face ID Authenticator

HYPR SDK for iOS: iOS Authenticators

πŸ“˜

Face in the Crowd

Any Face ID registered on the device can register/authenticate into your App.

Standard Face ID AAID (Authenticator ID)0045#1050
Full Basic Attestation Face ID AAID
(requires Advanced Device Protection)
0045#1051
Number of Retries for Enrollment2
Number of Retries for Authentication2
Number of Retries before Face ID Reader Is LockedUnlimited

Enrollment/Authentication Screen

1125

Invalid Face ID Screen

1125

Setup

  1. Create a group to contain the frameworks.
456
  1. Embed and link the HYPR Frameworks.
1647
  1. Follow the steps below to enable the Face ID Authenticator. Since this is done during App startup, place it in AppDelegate.swift.
import HyprCore
import HYPRFaceID

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  	HYPRUAFClient.registerAuthenticatorModule(HYPRFaceIDAsm.self)
  	HYPRUserAgent.setSSLPinningEnabled(false)
  	if HYPRUserAgent.sharedInstance().activeProfile() == nil {
  	let config = HYPRUserAgentProfileConfiguration(
    	rpAppId: "Relying Party App ID i.e: HYPRDefaultApplication",
      rpServerUrl: "Relying Party URL i.e.: https://9999-pov.hypr.com",
      deviceType: "WEB",
      rpSSLPinCredentials: nil,
      additionalData: nil)
  
  	let profile = HYPRUserAgentProfile(displayName: "Place a profile name name here: i.e. MyProfile",
    	configuration: config,
      persona: nil,
      userAccounts: nil)
      HYPRUserAgent.sharedInstance().registerProfile(profile!)
    }
    return true
  }
}

Register, Authenticate, Deregister

πŸ“˜

Create a Policy with FaceID

To dictate what authenticators to use during registration, authentication, and deregistration, you'll need to create a policy that includes the Face ID Authenticator.

See Policy Matching for greater detail.

Register

import HyprCore
  
class ViewController: UIViewController {
	func register() {
  	HYPRUserAgent.setParentViewController(self)
    HYPRUserAgent.sharedInstance().registerUser(withName: nil, action: "<policy name goes here>") { error in
    	if let error = error {
      	// Handle the error
      }
      else {
      	// Registration is successful
      }
    }
  }
}

Authenticate

By passing nil for the first argument, it will authenticate the current user.

import HyprCore
  
class ViewController: UIViewController {
	func authenticate() {
  	HYPRUserAgent.setParentViewController(self)
    HYPRUserAgent.sharedInstance().authenticateUser(nil, action: "<policy name goes here>") { error in
    	if let error = error {
      	// Handle the error
      }
      else {
      	// Authentication is successful
      }
    }
  }
}

Deregister

By passing nil for the first argument, it will deregister the current user.

import HyprCore
  
class ViewController: UIViewController {
	func deregister() {
  	HYPRUserAgent.setParentViewController(self)
    HYPRUserAgent.sharedInstance().deregisterUser(nil) { error in
    	if let error = error {
      	// Handle the error
      }
      else {
      	// Deregistration is successful
      }
    }
  }
}

UI Customization

To customize elements displayed by the HYPR SDK for iOS, use HYPRFaceIDAuthenticatorViewConfiguration sharedInstance to set properties describing the specific changes you want to make.

The HYPRFaceIDAuthenticatorViewConfiguration sharedInstance provides the following properties to style UI elements:

PropertyDescription
authenticationPromptTextText displayed to the user in the Face ID authentication alert
biometryLockoutVerifyAlertTitleText displayed to the user if authentication was unsuccessful
biometryLockoutEnrollAlertTitleText displayed to the user if enrollment was unsuccessful
biometryLockoutAlertCloseButtonTitleAlert cancellation button text
biometryLockoutAlertMessageText displayed to the user if authentication or enrollment were unsuccessful and amount of allowed attempt have exceeded

Example

import HyprCore
import HYPRFaceID

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    	let faceIDConfig = HYPRFaceIDAuthenticatorViewConfiguration.sharedInstance()
      faceIDConfig.authenticationPromptText = "This is the latest face id prompt text"
      faceIDConfig.biometryLockoutVerifyAlertTitle = "Verification failed"
      faceIDConfig.biometryLockoutEnrollAlertTitle = "Enrollment failed"
      faceIDConfig.biometryLockoutAlertCloseButtonTitle = "Close"
      faceIDConfig.biometryLockoutAlertMessage = "Try again later"
    return true
  }
}

Here is a full list of properties:

@interface HYPRFaceIDAuthenticatorViewConfiguration : NSObject <NSCopying, NSCoding>

+ (instancetype _Nonnull )sharedInstance;

/**
 * Face ID authenticator prompt text
 */
@property (nonatomic, copy, nullable) NSString *authenticationPromptText;
/**
 * Biometry lockout enroll alert title
 */
@property (nonatomic, copy, nullable) NSString *biometryLockoutEnrollAlertTitle;
/**
 * Biometry lockout verify alert title
 */
@property (nonatomic, copy, nullable) NSString *biometryLockoutVerifyAlertTitle;
/**
 * Biometry lockout alert message
 */
@property (nonatomic, copy, nullable) NSString *biometryLockoutAlertMessage;
/**
 * Biometry lockout alert close button title
 */
@property (nonatomic, copy, nullable) NSString *biometryLockoutAlertCloseButtonTitle;

@end