Register, Authenticate, and Deregister
HYPR SDK for iOS
This page explains how to register, authenticate, and deregister a user with the HYPR API. It also shows how to deregister a specific authenticator, for example to re-add with a new PIN.
Before You Start
This document assumes that you've set up the HYPR SDK in your iOS project by following the steps on the Quick Start page.
To define which authenticators are available for use during registration, authentication, and deregistration you first need to create a policy. See HYPR SDK for IOS Policy Matching for details.
Registering a User
- Set the
viewController
on which the HYPR SDK for IOS UI will be presented. - Register the user by calling the
registerUser()
method. If you passnil
for thename
parameter, the SDK will generate a unique name for you. Theaction
parameter should be the exact policy name you set in the Control Center.
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
}
}
}
}
Authenticating a User
- Set the
viewController
on which the HYPR SDK UI will be presented. - Authenticate by calling the
authenticateUser()
method. If you passnil
for thename
parameter, the HYPR SDK will authenticate the current user. Theaction
parameter should be the exact policy name you set in the Control Center.
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
}
}
}
}
Deregistering a User
- Deregister the user by calling the
deregisterUser()
method. If you passnil
for the user parameter, the HYPR SDK will deregister the current user.
import HyprCore
class ViewController: UIViewController {
func deregister() {
HYPRUserAgent.sharedInstance().deregisterUser(nil) { error in
if let error = error {
// Handle the error
}
else {
// Deregistration is successful
}
}
}
}
Getting Registered Authenticators
- To get a list of registered authenticators, pass the
userAccount
to theregisteredAuthenticators()
method. If you providenil
for theuserAccount
, the HYPR SDK will use the current active account.
The return value is a dictionary containing the authenticator attestation IDs (AAIDs) as keys and a list of every KeyId
for that AAID.
HYPRUserAgent.sharedInstance().registeredAuthenticators(forUser: <userAccount>, facetId: HYPRUAFClient.facetId())
Deregistering an Authenticator
- Deregister a specific authenticator by calling the
deregisterAuthenticator()
method. You'll need to specify the AAID you want to deregister, along with theuserAccount
. If you providenil
for theuserAccount
, the HYPR SDK will use the current active account.
HYPRUserAgent.sharedInstance().deregisterAuthenticator(withAAID: "AAID goes here", forUser: <userAccount>, facetId: HYPRUAFClient.facetId()) { error in
if let error = error {
// Error
}
else {
// Success! Authenticator has been removed
}
}
Updated 18 days ago