Skip to main content

Face Login

This guide explains how to use the face login feature in Welcome SDK.

Onboarding and Login

1. Create SelfieScan login flow

FlowConfig flowConfig = new FlowConfig.Builder()
.addSelfieScan(new SelfieScan.Builder()
.setShowTutorials(false)
.setMode(Mode.LOGIN)
.setCustomerToken(token)
.build())
.build();

Customer token uniquely identifies a customer in OMNI system and it's returned as a result of approve onboarding API call (e.g server REST API).

2. Create a callback to receive face login results

OnboardingListenerV2 onboardingListenerV2 = new IncodeWelcome.OnboardingListenerV2() {
@Override
public void onSelfieScanCompleted(SelfieScanResult selfieScanResult) {
// Selfie scan completed
}
}

3. Start the onboarding process

IncodeWelcome.getInstance().startOnboardingV2(this, null, flowConfig, onboardingListenerV2);

Optional: Use on-device face recognition and/or liveness detection

  1. Enable on-device face recognition and/or liveness detection during SDK initialization.
@Override
public void onCreate() {
super.onCreate();
...
new IncodeWelcome.Builder(this, WELCOME_API_URL, WELCOME_API_KEY)
.enableFaceLogin(true)
.enableLocalLiveness(true)
...
.build();
...
}

This will trigger additional download of proprietary libraries in runtime. Check optional early library download for optimizations.

NOTE: On-device face recognition is currently supported only when approving users from the client SDK.

  1. Enable local server face recognition and/or liveness when creating flow configuration
FlowConfig flowConfig = new FlowConfig.Builder()
.addSelfieScan(new SelfieScan.Builder()
.setShowTutorials(false)
.setMode(Mode.LOGIN)
.setFaceRecognitionMode(SelfieScan.FaceRecognitionMode.LOCAL)
.setLivenessDetectionMode(SelfieScan.LivenessDetectionMode.LOCAL)
.setCustomerToken(token)
.build())
.build();

Optional step for early library download

Welcome SDKs downloads additional proprietary libraries in runtime. Actual download of libraries happens only once per installation and it gets started on first startOnboardingV2() call.

The simplest way to download the libraries early is to use the following method which will download them in background:

IncodeWelcome.getInstance().downloadLibraries();

Note: If the SDK is started before download is complete, the SDK will show its built-in downloading UI.

The other way to download the libraries is to explicitly show the built-in downloading UI:

if (!IncodeWelcome.getInstance().isLibrariesReady()) {
IncodeWelcome.getInstance().startPrepareLibs(OnboardingActivity.this, new PrepareLibsListener() {
@Override
public void onSuccess() {
// SDK is ready for use
}

@Override
public void onError(Throwable error) {
}

@Override
public void onUserCancelled() {
}
});
}

If you want to provide your own UI for downloading libraries, use the following API calls:

if (!IncodeWelcome.getInstance().isLibrariesReady()) {
IncodeWelcome.getInstance().subscribeForLibrariesReady(new FaceRecognitionPrepareListener() {
@Override
public void onPrepareProgressUpdate(int progress) {
// Display progress UI while downloading libraries.
}

@Override
public void onFaceRecognitionReady() {
// Start using the SDK
}

@Override
public void onPrepareError(LibraryDownloadError error) {
// Couldn't download required libraries. Please make sure you have working internet connection.
}
});
}