idenfy_sdk_flutter 1.2.0 copy "idenfy_sdk_flutter: ^1.2.0" to clipboard
idenfy_sdk_flutter: ^1.2.0 copied to clipboard

outdated

iDenfy SDK for Flutter

Table of contents #

Getting started #

The @idenfy/idenfy_sdk_flutter is an official Flutter plugin, which provides an easier integration of iDenfy KYC services.

1. Obtaining an authentication token #

The SDK requires token for starting initialization. Token generation guide

2. Availability information & new project setup #

Minimum required versions by the platform:

IOS - 9

Android - API 19

If you are starting a new Flutter project you can follow Flutter install guide. Once the setup is completed successfully, you can add iDenfy SDK dependencies.

3. Adding iDenfy Flutter SDK #

To add iDenfy SDK plugin, open your project's pubspec.yaml file and append it with the latest iDenfy SDK flutter plugin:

dependencies:
    idenfy_sdk_flutter: ^x.y.z

3.1 Configuring Android project

Please make sure to enable multidex in app/build.gradle:

android {
  defaultConfig {
     multiDexEnabled true
  }
}

3.2 Configuring IOS project

NSCameraUsageDescription must be provided in the application's Info.plist file:

<key>NSCameraUsageDescription</key>
<string>Required for document and facial capture</string>

Install the pods:

cd ios
pod install
cd ..

4. Adding iDenfy Flutter SDK manually #

For more customization, you can use our sample in this repository

4.1 Configuring Android Project

Please make sure you use the latest iDenfy SDK dependency in build/gradle file:

dependencies {
    implementation "idenfySdk:com.idenfy.idenfySdk:x.y.z"
}

Having done that, sync gradle project files.

4.2 Configuring IOS Project

Please make sure you use the latest iDenfy SDK dependency in idenfy_sdk_flutter.podspec file:

s.dependency 'iDenfySDK/iDenfyLiveness', 'x.y.z'

After that, install the pods:

cd ios
pod install
cd ..

If you face compiling issues, like "using bridging headers with module interfaces is unsupported" you should set Build libraries for distribution to NO in your app build settings.

The example IOS app has the correct configuration.

Usage #

Firstly, import idenfysdkflutter.dart file:

import 'package:idenfy_sdk_flutter/idenfy_sdk_flutter.dart';

After successful integration you should be able to call IdenfySdkFlutter.start method.

If the project is not successfully compiled or runtime issues occur, make sure you have followed the steps. For better understanding you may check the sample app in this repository.

Once you have an authentication token, which can be retrieved with following code, found in the example app, you can call IdenfySdkFlutter.start:

  Future<String> getAuthTokenRequest() async {
      final response = await http.post(
        Uri.https(Constants.BASE_URL, '/api/v2/token'),
        headers: <String, String>{
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          'Authorization': 'Basic ' + base64Encode(utf8.encode('${Constants.apiKey}:${Constants.apiSecret}')),
        },
        body: jsonEncode(<String, String> {
          "clientId": Constants.clientId,
        }),
      );
      if (response.statusCode == 201) {
        return jsonDecode(response.body)["authToken"];
      } else {
        throw Exception('Failed to fetch token');
      }
    }

  Future<void> initIdenfySdk() async {
      IdenfyIdentificationResult idenfySDKresult;
      Exception localException;
      try {
      String authToken = await getAuthTokenRequest();
        idenfySDKresult = await IdenfySdkFlutter.start(authToken);
      } on Exception catch(e) {
        localException = e;
      }
  
      setState(() {
        _idenfySDKresult = idenfySDKresult;
        exception = localException;
      });
    }

Please make sure to provide your cliendId, apikey and apisecret constants, they can be found in constants.dart file:

const String BASE_URL = 'ivs.idenfy.com';
const String clientId = 'idenfySampleClientID';
const String apiKey = 'PUT_YOUR_IDENFY_API_KEY_HERE';
const String apiSecret = 'PUT_YOUR_IDENFY_API_SECRET_HERE';

Calling IdenfySdkFlutter.start with provided authToken:

  Future<void> initIdenfySdk() async {
    IdenfyIdentificationResult idenfySDKresult;
    String authToken = "TOKEN"
    try {
        idenfySDKresult = await IdenfySdkFlutter.start(authToken);
    } on PlatformException {
    }

    setState(() {
        _idenfySDKresult = idenfySDKresult;
    });

Callbacks #

Callback from the SDK can be retrieved from IdenfySdkFlutter.start future:

try {
    idenfySDKresult = await IdenfySdkFlutter.start(authToken);
} on PlatformException {
}

setState(() {
    _idenfySDKresult = idenfySDKresult;
});

Result is an IdenfyIdentificationResult class with AutoIdentificationStatus and ManualIdentificationStatus enums:

class IdenfyIdentificationResult {
    AutoIdentificationStatus autoIdentificationStatus;
    ManualIdentificationStatus manualIdentificationStatus;
}

Information about the IdenfyIdentificationResult autoIdentificationStatus statuses:

Name Description
APPROVED The user completed an identification flow and the identification status, provided by an automated platform, is APPROVED.
FAILED The user completed an identification flow and the identification status, provided by an automated platform, is FAILED.
UNVERIFIED The user did not complete an identification flow and the identification status, provided by an automated platform, is UNVERIFIED.

Information about the IdenfyIdentificationResult manualIdentificationStatus statuses:

Name Description
APPROVED The user completed an identification flow and was verified manually while waiting for the manual verification results in the iDenfy SDK. The identification status, provided by a manual review, is APPROVED.
FAILED The user completed an identification flow and was verified manually while waiting for the manual verification results in the iDenfy SDK. The identification status, provided by a manual review, is FAILED.
WAITING The user completed an identification flow and started waiting for the manual verification results in the iDenfy SDK. Then he/she decided to stop waiting and pressed a "BACK TO ACCOUNT" button. The manual identification review is still ongoing.
INACTIVE The user was only verified by an automated platform, not by a manual reviewer. The identification performed by the user can still be verified by the manual review if your system uses the manual verification service.

*Note The manualIdentificationStatus status always returns INACTIVE status, unless your system implements manual identification callback, but does not create a separate waiting screen for indicating about the ongoing manual identity verification process. For better customization we suggest using the immediate redirect feature . As a result, the user will not see an automatic identification status, provided by iDenfy service. The SDK will be closed while showing loading indicators.

Additional customization #

Currently, @idenfy/idenfysdk_flutter_plugin does not provide customization options via Dart code directly. For any additional SDK customization, you need to use the sample in this repository and edit native code inside of the plugin.

We suggest creating a fork of this repository. After editing the code, you can include the plugin in the following way:

dependencies:
    idenfy_sdk_flutter: ^x.y.z
      git: https://github.com/your_repo/FlutterSDK.git

Android customization: Follow Android native SDK guide and edit IdenfysdkFlutterPlugin.kt.

IOS customization: Follow IOS native SDK guide and edit SwiftIdenfysdkFlutterPlugin.swift.

SDK Integration tutorials #

For more information visit SDK integration tutorials.