VerID
@objc
public final class VerID : NSObject
Provides access to essential Ver-ID functions.
-
Shared instance of Ver-ID
Declaration
Swift
@objc public static let shared: VerID
-
Load Ver-ID and its resources and authenticate the client app.
Note
It’s best practice to set the API secret in your Info.plist file and leave theapiSecret
parameternil
.See also
unload()
Declaration
Swift
@objc public func load(_ apiSecret: String? = nil, resourcesURL: URL? = nil, clearDatabase: Bool = false, callback: ((Bool,Error?) -> Void)? = nil)
Parameters
apiSecret
Ver-ID API secret. Overrides API secret set in your Info.plist file.
resourcesURL
URL from which to download Ver-ID resources. Set to
nil
if you bundle the resources in the VerIDModels folder in your app.clearDatabase
Setting this to
true
will clear all registered users and faces and return the Ver-ID database to the same state as when the app was first installed.callback
Block to be executed when Ver-ID is loaded. The block’s
error
parameter will not benil
if the client app authentication fails. -
Unload Ver-ID. Unload Ver-ID and release its resources. You must call
load()
orloadAsync(_:)
again prior to calling any Ver-ID methods.See also
load(_:resourcesURL:callback:)
Declaration
Swift
@objc public func unload()
-
Determine whether Ver-ID has been loaded.
true
if Ver-ID has been loaded and is ready to use.See also
load(_:resourcesURL:callback:)
Declaration
Swift
@objc dynamic fileprivate(set) public var isLoaded: Bool
-
Authentication security level. Choose higher levels for stricter authentication or lower levels to be more forgiving.
See also
VerIDSecurityLevel
Declaration
Swift
@objc public var securityLevel: VerIDSecurityLevel { get set }
-
List of registered Ver-ID users.
Declaration
Swift
@objc public func registeredVerIDUsers() throws -> [VerIDUser]
Return Value
registered users
-
Declaration
Swift
public func authenticateUser(id: String, inFaces faces: [VerIDFace], withStrictBearingMatch bearingMatch: Bool = false, callback: @escaping (Bool?,Error?) -> Void)
Parameters
id
ID of the user to authenticate
faces
Faces in which to authenticate the user. Must be suitable for recognition
bearingMatch
true
to make the bearing detected in the faces match exactly the registered face bearing. Setting this totrue
assumes that the user registered a face with the bearing in a session wherelivenessDetection
was set tostrict
. Otherwise the callback returns an error.callback
Callback to invoke on completion
-
Authenticate user in faces
Throws
Error if the authentication failsDeclaration
Swift
public func authenticateUser(id: String, inFaces faces: [VerIDFace], withStrictBearingMatch bearingMatch: Bool = false) throws -> Bool
Parameters
id
ID of the user to authenticate
faces
Faces in which to authenticate the user. Must be suitable for recognition
bearingMatch
true
to make the bearing detected in the faces match exactly the registered face bearing. Setting this totrue
assumes that the user registered a face with the bearing in a session wherelivenessDetection
was set tostrict
. Otherwise the call throws an error.Return Value
True if the user has been authenticated in at least one of the faces
-
Register faces as user
Throws
Error if the registration failsDeclaration
Parameters
faces
Faces to register. Must be suitable for recognition
id
ID of the user to register in the faces
append
True to append the faces if the user already exists. False will delete the user first
Return Value
The registered user
-
Register faces as user
Declaration
Parameters
faces
Faces to register. Must be suitable for recognition
id
ID of the user to register in the faces
append
True to append the faces if the user already exists. False will delete the user first
callback
Callback to invoke on completion
-
Compare two faces to each other
Throws
Exception if the call failsDeclaration
Parameters
face1
First face to compare to second face
face2
Second face to compare to first face
Return Value
NSNumber with a floating point integer comparison score ranging between 0 (different) and 1 (same)
-
Compare two faces to each other
Declaration
Parameters
face1
First face to compare to second face
face2
Second face to compare to first face
callback
Callback that returns either a NSNumber with a floating point integer comparison score ranging between 0 (different) and 1 (same) or error if the call fails
-
Discard faces when they’re no longer needed for recognition
Declaration
Swift
public func discardFaces(_ faces: [VerIDFace])
Parameters
faces
Faces to discard
-
Deregister the user and delete the associated account. Subsequent attempts to authenticate as this user will fail.
Declaration
Swift
@objc public func deregisterUser(_ userId: String, callback: ((Error?) -> Void)? = nil)
Parameters
userId
The user to deregister
-
Find out whether a user with the given id is registered.
Declaration
Swift
public func isUserRegistered(_ userId: String) throws -> Bool
Parameters
userId
the user id
Return Value
true if the user is registered
-
Get a profile picture for a user with the given id. This is one of the images captured when the user registers.
Declaration
Swift
@objc public func userProfilePicture(_ userId: String) -> UIImage?
Parameters
userId
the user id
Return Value
an image that can be used as a profile picture or nil if the picture or the user is unavailable
-
Detect faces in the supplied UIImage. The function will return right away and run the callback block when the detection completes. It’s safe to call on the main queue.
Declaration
Swift
@objc public func detectFaceInImage(_ image: UIImage, keepForRecognition: Bool, withStrictBearingMatching strictBearingMatching: Bool = false, callback: @escaping (_ face: VerIDFace?) -> Void)
Parameters
image
The image in which to detect faces
keepForRecognition
Set to
false
unless you are planning to use the face for operations that require face recognition like registration or authentication.strictBearingMatching
Set to
true
if you anticipate using the face for face recognition where the face must match the bearing of the registered face. This is used for example in sessions that usestrict
liveness detection level.callback
The block to execute when the face detection completes
-
Detect faces in the supplied UIImage. The function will block until the detection completes. Should be called on a background queue.
Throws
Error if a face cannot be found in the imageDeclaration
Swift
@objc public func detectFaceInImage(_ image: UIImage, keepForRecognition: Bool, withStrictBearingMatching strictBearingMatching: Bool = false) throws -> VerIDFace
Parameters
image
The image in which to detect faces
keepForRecognition
Set to
false
unless you are planning to use the face for operations that require face recognition like registration or authentication.strictBearingMatching
Set to
true
if you anticipate using the face for face recognition where the face must match the bearing of the registered face. This is used for example in sessions that usestrict
liveness detection level.Return Value
Detected face
-
Detect faces in the supplied PhotoKit asset. The function will return right away and run the callback block when the detection completes. It’s safe to call on the main queue.
Declaration
Swift
public func detectFaceInPHAsset(_ asset: PHAsset, callback: @escaping (_ faces: VerIDFace?) -> Void)
Parameters
asset
The PhotoKit asset in which to detect faces
callback
The block to execute when the face detection completes
-
Detect faces in the supplied PhotoKit PHAsset. The function will block until the detection completes. Should be called on a background queue.
Declaration
Swift
public func detectFaceInPHAsset(_ asset: PHAsset) -> VerIDFace?
Parameters
asset
The PhotoKit asset in which to detect faces
Return Value
Array of faces detected in the image