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 theapiSecretparameternil.See also
unload()Declaration
Swift
@objc public func load(_ apiSecret: String? = nil, resourcesURL: URL? = nil, clearDatabase: Bool = false, callback: ((Bool,Error?) -> Void)? = nil)Parameters
apiSecretVer-ID API secret. Overrides API secret set in your Info.plist file.
resourcesURLURL from which to download Ver-ID resources. Set to
nilif you bundle the resources in the VerIDModels folder in your app.clearDatabaseSetting this to
truewill clear all registered users and faces and return the Ver-ID database to the same state as when the app was first installed.callbackBlock to be executed when Ver-ID is loaded. The block’s
errorparameter will not benilif 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.
trueif 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
VerIDSecurityLevelDeclaration
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
idID of the user to authenticate
facesFaces in which to authenticate the user. Must be suitable for recognition
bearingMatchtrueto make the bearing detected in the faces match exactly the registered face bearing. Setting this totrueassumes that the user registered a face with the bearing in a session wherelivenessDetectionwas set tostrict. Otherwise the callback returns an error.callbackCallback 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 -> BoolParameters
idID of the user to authenticate
facesFaces in which to authenticate the user. Must be suitable for recognition
bearingMatchtrueto make the bearing detected in the faces match exactly the registered face bearing. Setting this totrueassumes that the user registered a face with the bearing in a session wherelivenessDetectionwas 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
facesFaces to register. Must be suitable for recognition
idID of the user to register in the faces
appendTrue 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
facesFaces to register. Must be suitable for recognition
idID of the user to register in the faces
appendTrue to append the faces if the user already exists. False will delete the user first
callbackCallback to invoke on completion
-
Compare two faces to each other
Throws
Exception if the call failsDeclaration
Parameters
face1First face to compare to second face
face2Second 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
face1First face to compare to second face
face2Second face to compare to first face
callbackCallback 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
facesFaces 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
userIdThe user to deregister
-
Find out whether a user with the given id is registered.
Declaration
Swift
public func isUserRegistered(_ userId: String) throws -> BoolParameters
userIdthe 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
userIdthe 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
imageThe image in which to detect faces
keepForRecognitionSet to
falseunless you are planning to use the face for operations that require face recognition like registration or authentication.strictBearingMatchingSet to
trueif 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 usestrictliveness detection level.callbackThe 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 -> VerIDFaceParameters
imageThe image in which to detect faces
keepForRecognitionSet to
falseunless you are planning to use the face for operations that require face recognition like registration or authentication.strictBearingMatchingSet to
trueif 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 usestrictliveness 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
assetThe PhotoKit asset in which to detect faces
callbackThe 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
assetThe PhotoKit asset in which to detect faces
Return Value
Array of faces detected in the image
VerID Class Reference