blusalt_liveness_native 0.1.25 copy "blusalt_liveness_native: ^0.1.25" to clipboard
blusalt_liveness_native: ^0.1.25 copied to clipboard

Liveness SDK for Android and IOS

blusalt_liveness_native #

Facial Comparison and Face Detection SDK for Android and IOS

Get your Liveness credentials from Blusalt

Features #

Facial comparison (LivenessFacialComparisonType)

  1. Dynamic Liveness Detection (Motional): This method verifies liveness by requiring the user to perform specific actions like opening their mouth or shaking their head. It's strict because attempts to bypass the action (like holding a still image) will be detected and likely terminate the process.
  2. Static Liveness Detection (Still): This approach asks users to position their face within the camera frame and validates liveness based on facial data points. It's less strict than the dynamic method. If users struggle with finding the right camera position, the process might not automatically terminate, allowing them to adjust.

Face Detection (LivenessDetectionOnlyType)

  1. Dynamic Liveness Detection (Motional)
  2. Static Liveness Detection (Still)
  3. Flash Liveness Detection (Flash): This method is only available for facial detection, not facial comparison. It works similarly to the static method but increases the device screen brightness to enhance facial data point detection.

Usage #

dependencies:
  blusalt_liveness_native: ^lastVersion 

Example #

///[thresholdInPercent] ranges between 0-100. The higher the value, the stricter the facial comparison.
///When set to null or no value is passed, it will use the default value from SDK which ranges from 90-94.
///
///[timeoutDurationInSec] this value can be used top override the timeout duration of networks calls in the SDK.
///When set to null or no value is passed, it will use the default value from SDK 120s.
///
/// [startProcessOnGettingToFirstScreen] starts the SDK on getting to the SDK homepage
/// rather than making user click continue button.
startFacialComparisonSDK() async {
  BlusaltLivenessResultResponse? response =
  await _livenessPlugin.startFacialComparisonSDK(
      apiKey: apiKey,
      appName: appName,
      clientId: clientId,
      isDev: isDev,
      livenessFacialComparisonType:
      LivenessFacialComparisonType.motional, 
      startProcessOnGettingToFirstScreen: true,
      thresholdInPercent: null,
      timeoutDuration: null);
}

startLivenessDetectionOnlySDK() async {
  BlusaltLivenessResultResponse? response =
  await _livenessPlugin.startLivenessDetectionOnlySDK(
      apiKey: apiKey,
      appName: appName,
      clientId: clientId,
      isDev: isDev,
      livenessDetectionOnlyType:
      LivenessDetectionOnlyType.still,
      startProcessOnGettingToFirstScreen: true,
      timeoutDuration: null);
}

Installation #

Android #

Step 1

Create a [github.properties] file in root of android folder and put below into content. Replace values with your github credentials from github and make sure to grant necessary permissions especially for github packages

USERNAME_GITHUB=SampleUsername
TOKEN_GITHUB=SampleClassicToken

Step 2

Add below to project level gradle file /android/build.gradle

buildscript {
    ext.kotlin_version = '1.9.+'
    ...

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.+'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    def githubPropertiesFile = rootProject.file("github.properties")
    def githubProperties = new Properties()
    githubProperties.load(new FileInputStream(githubPropertiesFile))


    repositories {

        maven {
            name "GitHubPackages"
            url 'https://maven.pkg.github.com/Blusalt-FS/Liveness-Only-Android-Package'

            credentials {
                username githubProperties['USERNAME_GITHUB']
                password githubProperties['TOKEN_GITHUB']
            }
        }
    }
}

Step 3

Change the minimum Android sdk version to 24 (or higher) in your /android/app/build.gradle file.


android {
    ...
    defaultConfig {
      ...
      minSdkVersion 24
    }
    ...
}

Step 4

If you're experiencing crashes or timeouts. Add below to your progaurd.pro file if using progaurd or minify is enabled /android/app/proguard-rules.pro

-keep public class com.megvii.**{*;}
-keep class net.blusalt.liveness_native.** { *; }

Enable proguard in /android/app/build.gradle file like below.


android {
    
    ...
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    ...
}

Note on Android: #

If you are getting an error on android which says "Unauthorized" when gradle is downloading or building, generate a new github token that have access to clone, read and write to repo, access github packages. If you don't know which to tick, tick all boxes. Cheers

iOS #

Minimum iOS Deployment = 14

Add one row to the ios/Runner/Info.plist:

with the key Privacy - Camera Usage Description and a usage description.

<key>NSCameraUsageDescription</key>
<string>your usage description here</string>

Note on iOS #

  1. This Plugin will only work properly on a physical ios device, iOS Simulators are not supported.
  2. If you get an error while compiling about MediaPlayer or Webkit missing. On xcode, click on Runner, under TARGETS, click Runner, Under General Tab, scroll down to Frameworks, Libraries and Embedded Contents, Click the + icon, search and add each of frameworks AVFoundation.framework, CoreMedia.framework, CoreMotion.framework, MediaPlayer.framework, SystemConfiguration.framework, WebKit.framework
2
likes
140
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

Liveness SDK for Android and IOS

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on blusalt_liveness_native