Youverify Liveness iOS SDK

Our iOS SDK enables seamless integration of real-time liveness detection into your mobile applications. To get started with our SDK, follow the guide below:

Get your Public Merchant Key

Installation

To install, run one of the following commands:

pod 'pod 'YouVerifyLivenessSDK'

Usage

  1. Import the package into your web page like so:

import YVLivenessSDK
  1. Initialize an instance of the package, like so:

@StateObject var yvLiveness: IosSDK

_yvLiveness = StateObject(wrappedValue: IosSDK(options))

For a list of the valid options, check this out

  1. Start the process, like so:

yvLiveness.startSDK();

This could also be called with an array of tasks. The supplied tasks override those provided during initialization.

let livenessTasks = [
    TaskProperties(task: 
        YVTask.completeTheCircle(CompleteTheCircleTask(difficulty: .medium))
    )
]

yvLiveness.startSDK(tasks: livenessTasks)
  1. Add the SDKView to your page, and the controls for the modal as so:

if iosSDK.isDialogVisible {
    SDKView(
        sdk: iosSDK
    )
}

Full Example:

@StateObject var iosSDK: IosSDK

init() {
    _iosSDK = StateObject(wrappedValue: IosSDK(
        publicKey: "PUBLIC_KEY",
        user: SDKUser,
        onSuccess: {data in
            print("The data returned is \(data)")
        }
    ))
}

Button(action: {
    iosSDK.startSDK(tasks: [
        TaskProperties(task: 
            YVTask.completeTheCircle(CompleteTheCircleTask(difficulty: .medium))
        )
    ])
}) {
    Text("Complete the Circle")
}

if iosSDK.isDialogVisible {
    SDKView(
        sdk: iosSDK
    )
}

Options

Option
Type
Required
Description
Default Value
Possible Values

sandboxEnvironment

Boolean

No

Sets whether session should run in sandbox or live mode

true

true, false

tasks

Array

No

NoSets tasks that need to be performed for liveness to be confirmed

nil

See tasks

user

Class

Yes

Sets details of user for which liveness check is being performed

-

Any string

user.firstName

String

Yes

First name of user

-

Any string

user.lastName

String

No

Last name of user

nil

Any string

user.email

String

No

Email of user

nil

Any string

onClose

Function

No

Callback function that gets triggered when modal is closed

nil

Any valid function

onSuccess

Function

No

Callback function that gets triggered when all tasks have been completed and passed. Called with completion data

nil

Any valid function

onFailure

Function

No

Callback function that gets triggered when at least one task fails. Called with completion data

nil

Any valid function

Tasks

A task is a series of instructions for users to follow to confirm liveness. Find below a list of tasks.

PS: We aim to frequently add to this list a variety of fun and yet intuitive ways of confirming liveness, so be on the lookout for more tasks!

They are:

Complete The Circle

User passes task by completing imaginary circle with head movement.

CompleteTheCircleTask option

Option
Type
Required
Description
Default Value
Possible Values

difficulty

TaskDifficulty

No

Sets difficulty of task

.medium

.easy, .medium, .hard

timeout

Number

No

Sets time in milliseconds after which task automatically fails

nil

Any number in milliseconds

Yes Or No

User passes task by answering a list of arbitrary questions set by you with the tilting of the head; right for a yes and left for a no.

YesOrNoTask option

Option
Type
Required
Description
Default Value
Possible Values difficulty

difficulty

TaskDifficulty

No

Sets difficulty of task

.medium

.easy, .medium, .hard

timeout

Number

No

Sets time in milliseconds after which task automatically fails

nil

Any number in milliseconds

questions

Array

No

A set of questions to ask user

nil

See nested options below

questions.question

String

Yes

Question to ask user. Should be a true or false type question. Eg: "Are you ready"

-

Any string

questions.answer

Bool

Yes

Answer to the question

-

true, false

questions.errorMessage

String

No

Error message to display if user gets question wrong

undefined

Any string

Motions

User passes task by performing random motions in random sequences, which include nodding, blinking and opening of mouth.

MotionsTaskClass option

Option
Type
Required
Description
Default Value
Possible Values

difficulty

TaskDifficulty

No

Sets difficulty of task

.medium

.easy, .medium, .hard

timeout

TimeInterval

No

Sets time in milliseconds after which task automatically fails

nil

Any number in milliseconds

maxNods

Int

No

Maximum amount of nods a user is asked to perform

5

Any number

maxBlinks

Int

No

Maximum amount of nods a user is asked to perform

5

Any number

TaskProperties

User passes in the class and preferred settings for each task.

Option
Type
Required
Description
Default Value
Possible Values

task

YVTask

Yes

Id of task

-

YVTask.completeTheCircle(Task_class eg. CompleteTheCircleTask)

timeout

TimeInterval

No

Sets time in milliseconds after which task automatically fails

nil

Any number in milliseconds

Liveness Data

The onSuccess and onFailure callbacks (if supplied) are passed the following data:

Option
Type
Description

data

Object

Data passed through callback

data.faceImage

String

Face Image of user performing liveness check

data.livenessClip

String

Video of user performing liveness check

data.passed

Bool

Indicator on whether liveness check passed or failed

data.metadata

Any

Metadata passed in during initialization

Credits

This SDK is developed and maintained solely by Youverify

Last updated

Was this helpful?