intp_flutter_liveness_sdk 1.3.6

SDKflutter
Platformandroidios

The Flutter SDK built incorporates the view of the liveness detection video recording feature.

LivenessCamera SDK Guide

Platform Support

AndroidiOS
✔️✔️

Installation

iOS

Add three rows to the ios/Runner/Info.plist:

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

Editing Info.plist as text, add:

  <key>NSCameraUsageDescription</key>
  <string>Camera Access</string>
  <key>NSMicrophoneUsageDescription</key>
  <string>Microphone Access</string>

Android

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

  minSdkVersion 21

Usage

You can use LivenessCamera SDK to detection step of your e-KYC flow. This works both on Android and iOS.

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intp_flutter_liveness_sdk/intp_flutter_liveness_sdk.dart';

Future<void> main() async {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Liveness detection'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Future<String?> buildDialog(Map<String, dynamic> value) {
    debugPrint("_buildDialog: $value");

    String content = "Detection failed !!!";

    if (value['Liveness'] != null && value['Liveness']['detectSuccess']) {
      content = "Detection success !!!";
    }

    if (value['statusCode'] != null && value['statusCode'] != 200) {
      content = "Error : $value";
    }

    return showDialog<String>(
      context: context,
      builder: (BuildContext context) => AlertDialog(
        title: const Text('Result'),
        content: Text(content),
        actions: <Widget>[
          TextButton(
            onPressed: () => Navigator.pop(context, 'OK'),
            child: const Text('OK'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SafeArea(
        child: LivenessCamera(
          livenessResponse: (Map<String, dynamic> value) {
            // handle your next event or navigation from below
            buildDialog(value);
          },
          endpoint: "API_ENDPOINT",
          apiKey: "API_KEY",
          transactionId: "TRANSACTION_ID",
          // actionsInstruction: const {
          //   'SHAKE_LEFT': 'New caption turn your head left',
          //   'SHAKE_RIGHT': 'New caption turn your head right',
          //   'NOD_HEAD': "New caption nod your head",
          //   'MOUTH': "New caption open your mouth",
          // },
          // numberOfActions: 2,
          // numberOfRetry: 1,
          // backgroundColor: Colors.red,
          // fontFamily: "Kanit-Regular", /* Load font from assets */
        ),
      ),
    );
  }
}

Options

Available options in LivenessCamera

PropertyTypeStatusDefaultDescription
livenessResponseFunctionrequiredReceiving function for liveness result
endpointStringrequiredThe API endpoint
apiKeyStringrequiredThe API key generated from Finema for the customer to use
transactionIdStringrequiredThe transaction id generated from Finema for the customer to use
actionsInstructionMap<String, dynamic>optional
{
'SHAKE_LEFT': 'Turn your head left',
'SHAKE_RIGHT': 'Turn your head right',
'NOD_HEAD': 'Nod your head',
'MOUTH': 'Open your mouth',
}
Custom text instruction each action
numberOfActionsIntoptional1The number of randomised action out of 4 actions ['SHAKE_LEFT', 'SHAKE_RIGHT', 'NOD_HEAD', 'MOUTH'] This value can be between 1 and 4
numberOfRetryIntoptional0The number of retries that should be performed if the user fails the liveness check. The SDK will repeat up to and including this if the user fails the test repeatedly before failing the entire flow
backgroundColorColoroptionalColors.whiteBackground color
fontFamilyStringoptional"Roboto"Font family from your assets
prepareTextStringoptional"Ensure your face is in the circle"Prepare text
titleFontColorColoroptionalColors.black87Font color
titleFontSizeDoubleoptional20Font size
loadingColorColoroptionalColors.whiteLoading indicator color
loadingSizeDoubleoptional20Loading indicator size
loadingTextStringoptional"Loading..."Loading text
verifyTextStringoptional"Verify..."Verify text
loadingFontColorColoroptionalColors.whiteText color of loadingText, verifyText
loadingFontSizeDoubleoptional16Text size of loadingText, verifyText
subtitleFontSizeDoubleoptional12Text size of recordText, uploadText
recordTextStringoptional"Recording in process..."Indicator record step
uploadTextStringoptional"Upload in process..."Indicator upload step
buttonLabelStringoptional"Tap to start"Button label
buttonStyleButtonStyleoptional
ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.blue),
textStyle: MaterialStateProperty.all(
TextStyle(
fontFamily: widget.fontFamily
),
),
),
Custom button style for look and feel match your CI
buttonPaddingEdgeInsetsoptionalEdgeInsets.all(25)Padding of button
hintPositionFromBottomDoubleoptionalscreen height * 0.15Adjust hint position from bottom
buttonPositionFromBottomDoubleoptionalscreen height * 0.01Adjust button position from bottom

Response

Available properties in response

PropertyTypeDescription
detectSuccessBooleanDetection status
detectActionsResultArray of objectArray of detection results
totalRetryIntTotal number of retry
statusCodeIntHTTP response error status codes
errorMessageStringHTTP response error message