> For the complete documentation index, see [llms.txt](https://docs.1kosmos.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.1kosmos.com/mobile-sdk/flutter-integration-guide.md).

# Flutter Integration Guide

### Overview

Flutter is an open-source UI software development kit created by Google. It lets you build natively compiled applications for mobile, web, and desktop from a single codebase. It uses the Dart programming language and provides a rich set of pre-designed widgets and tools that let developers create highly customizable, expressive, high-performance interfaces.

The BlockID SDK is a cross-platform dependency compatible with both Android and iOS. You can easily integrate it into native Android apps using Gradle, while iOS apps can incorporate it with CocoaPods.

Here are the key features of the BlockID SDK:

* **One-Time Passcode**: Generate a one-time passcode displayed in a mobile app, providing an additional Multi-Factor Authentication (MFA) layer.
* **ID Card Verification**: Scan, extract, and verify ID cards from a specified list of countries.
* **Driver’s License Verification**: Scan, extract, and verify driver’s licenses from a specified list of countries.
* **Passport Verification**: Scan, extract, and verify passports from a specified list of countries.
* **Live ID Enrollment**: Allow users to enroll their face for liveness detection.
* **Live ID Verification**: Prompt users to verify their face against a previously enrolled image for identity confirmation.
* **Passwordless Login**: Utilize a QR code for secure login approval via a trusted device.
* **Enroll TouchID / FaceID**: Leverage the native biometric of the device to unlock the application.
* **License Key Management**: Use a license key to manage the blockidplugin efficiently. The following screenshot illustrates the features of BlockID SDK:

Starting with Release v1.10.70, the BlockID SDK has been integrated with the Flutter framework through a plugin/bridge. This plugin serves as a wrapper for the native BlockID SDKs on iOS and Android, facilitating interaction with the SDKs across both platforms so that the BlockID services can be seamlessly used on Android/iOS applications built with Flutter.

#### System Requirements

Before getting started, make sure you meet the following prerequisites:

* Ensure that the Flutter development environment is set up on your system.
* Android API Level 28 / Android OS 9 or higher
* iOS 16.0 or higher
* Java 17
* Gradle 9.3.1
* Android Gradle Plugin (AGP) 9.0.0

### Integrating blockidplugin with Flutter Project

To seamlessly incorporate the flutter\_blockidplugin into your Flutter project, follow these steps:

1. Create your flutter project. For example, `flutter create name_of_the_project`.
2. To integrate the flutter\_blockidplugin, open the **pubspec.yaml** file and add the following dependencies.

   ```
   flutter_blockidplugin: 
     Git: 
     url: https://github.com/1KBlockID/flutter-blockid-demo-app 
     ref: main

   ```
3. After including the dependency, run the `flutter pub get` command in the terminal.

### Managing Configurations in iOS/Android Platforms

To use Android/iOS Flutter applications, you must configure specific dependencies into your Flutter project's Android/iOS directories.

#### Configuring iOS

The iOS plugin uses Swift Package Manager (SPM) to manage the BlockID SDK dependency automatically. When you run flutter pub get and pod install, the plugin's Package.swift pulls in ios-blockidsdk version 1.30.60 along with all required dependencies.

#### Configuring iOS Directory

Make the following changes to the `Podfile` in the iOS directory of your Flutter project.

{% hint style="info" %}
Note:

Check if you already have a `Podfile` in the `iOS` directory. If not, run the `pod init` command in the terminal. This command will initialize a Podfile for your project.
{% endhint %}

1. Open the **Podfile** in the text editor of your choice.
2. Add the supported iOS version in the pod file header as shown below.

```ruby
platform :ios, '16.0'
```

3. Add the following configuration to the **Podfile**.

```ruby
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|

      # set build library for distribution to true
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'

      # set iOS Deployment Target to 16.0
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'

      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        'PERMISSION_CAMERA=1'
      ]
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end
```

4. Save the `Podfile` and run the `pod install` command to install the specified pods.

#### **Configuring Android Directory**

To configure the files inside the Android directory of your flutter project, follow these steps:

**Step 1**: Adding Repositories

Navigate to the `<project>/android/app/build.gradle` file and make the following changes under the **allprojects > repositories** section.

```groovy
allprojects {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
        maven {
            url 'https://artifactory.1kosmos.net/artifactory/maven-releases-local/'
            credentials {
                username = 'developer'
                password = 'q5k#06ZcjSo#'
            }
        }
        maven { url "https://jitpack.io" }
    }
}
```

Also add AGP version enforcement for subprojects:

```groovy
subprojects { subproject ->
    subproject.buildscript {
        configurations.configureEach {
            resolutionStrategy {
                eachDependency { details ->
                    if (details.requested.group == 'com.android.tools.build' && details.requested.name == 'gradle') {
                        details.useVersion '9.0.0'
                    }
                }
            }
        }
    }
}
```

`android/settings.gradle`

Ensure AGP 9.0.0 is specified:

```groovy
plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "9.0.0" apply false
}
```

`android/gradle/wrapper/gradle-wrapper.properties`

Ensure Gradle 9.3.1:

```
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
```

**Step 2**: Modify the Gradle build configurations

1. Specify the `minSdkVersion` property as 28 and set the Java compatibility as Java 17.

```groovy
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
        }
    }

    defaultConfig {
        minSdkVersion 28
    }
}
```

2. Add packaging options using the new DSL.

```groovy
android {
    packagingOptions {
        jniLibs {
            excludes += [
                'lib/x86_64/freebsd/libscrypt.so',
                'lib/x86_64/linux/libscrypt.so',
                'lib/x86_64/darwin/libscrypt.dylib'
            ]
        }
        resources {
            excludes += [
                'META-INF/rxjava.properties',
                'AndroidManifest.xml',
                'META-INF/INDEX.LIST',
                'META-INF/LICENSE.md',
                'META-INF/DEPENDENCIES',
                'META-INF/NOTICE.md',
                'META-INF/FastDoubleParser-LICENSE',
                'META-INF/FastDoubleParser-NOTICE',
                'META-INF/io.netty.versions.properties',
                'META-INF/DISCLAIMER',
                'META-INF/*.SF',
                'META-INF/*.DSA',
                'META-INF/*.RSA',
                'META-INF/MANIFEST.MF'
            ]
        }
    }
}
```

3. Add the following configurations to the root level of the build.gradle file.

```groovy
configurations.configureEach {
    resolutionStrategy {
        force 'androidx.test.espresso:espresso-core:3.6.1'
        force 'androidx.test.espresso:espresso-idling-resource:3.6.1'
    }
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'org.bouncycastle') {
            details.useVersion '1.84'
        }
    }
}
```

**Step 3**: Add Permissions to the **AndroidManifest.xml** file.

The BlockID SDK requires the following permissions. Add them to your **AndroidManifest.xml** file by navigating to the `[project]/android/app/src/debug` folder.

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:label="appname"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/LaunchTheme"
        android:allowBackup="true"
        tools:replace="android:allowBackup,android:theme,android:label"/>
</manifest>
```

**Step 4**: Run the flutter project.

### **Importing flutter\_blockidplugin to your Project**

To seamlessly use the BlockID app's functionality, run the following command to import the blockidplugin into your Flutter project.

```dart
import 'package:flutter_blockidplugin/index.dart';
```

**Sample**

```dart
final _blockidpluginPlugin = Blockidplugin();
await _blockidpluginPlugin.setLicenseKey(YOUR_KEY);
```

### **Managing Functionalities in the Sample Project**

After creating the sample project, the following BlockID app functionalities can be explored in the Flutter Android/iOS applications:

* SDK Setup functions
* Get DID
* Get Version
* Biometric Enrollment
* Biometric Verification
* Create a one-time passcode
* LiveID Enrollment
* LiveID Verification
* Document Enrollment
* Login with a QR Code
* Locking and Unlocking SDK
* Resetting SDK

#### **SDK Setup functions**

You can set up an SDK to manage the license key, wallet, and tenant. The following table provides information on various SDK functions:

| Function          | Description                                     | Container                                                                                           |
| ----------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| Set License Key   | Set the license key to access the blockidplugin | `await _blockidpluginPlugin.setLicenseKey(const_licenseKey);`                                       |
| Initialize Wallet | Create a wallet for the application             | `final status = await _blockidpluginPlugin.initiateTempWallet();`                                   |
| Register Tenant   | Register the tenant with the SDK                | `final status = await _blockidpluginPlugin.registerTenant(const_tag, const_community, const_dns,);` |

#### **Get DID**

To retrieve the unique Distributed IDentifier (DID) of the application, run the following command. Its response is displayed as a String.

```dart
final response = await _blockidpluginPlugin.getDID();
// response will have DID as String
```

#### **Get Version**

To retrieve the version of the currently used BlockID SDK, run the following command.

```dart
final response = await _blockidpluginPlugin.blockIDSDKVersion();
```

#### **Biometric Details**

Use this functionality to scan your biometric data to unlock the BlockID SDK and gain access to its functionality.

To enroll a biometric, run the following command:

```dart
final status = await _blockidpluginPlugin.enrollDeviceAuth();
```

To verify if any biometric data has already been enrolled, run the following command:

```dart
final status = await _blockidpluginPlugin.verifyDeviceAuth();
```

To check if the biometric has been registered, run the following command:

```dart
final status = await _blockidpluginPlugin.isDeviceAuthRegistered();
```

#### **One-time passcode**

Obtain the time-based OTP from the blockidplugin by running the following command:

```dart
final response = await _blockidpluginPlugin.totp();
```

Its response will be of the type TOTP and provide the following objects:

| Parameter        | Description                                                                                           |
| ---------------- | ----------------------------------------------------------------------------------------------------- |
| totp             | String: Displays a time-based one-time password (OTP).                                                |
| getRemainingSecs | Int: Displays the time after which the OTP expires. The default expiry time of the OTP is 30 seconds. |

#### **LiveID Enrollment**

You can perform the following functions during the enrollment of liveID:

a. **Enroll LiveID** – Use the following command to enroll the liveid.

```dart
await _blockidpluginPlugin.enrollLiveIDScanning(
        scannerViewId,
        dvcID: const_dvcID, // this param is optional, can be omitted
        mobileSessionId: random_UUID, // optional param
        mobileDocumentId: "liveid_$random_UUID", // optional param
        ); 
```

**Method Summary**

| Parameter        | Description                                                             |
| ---------------- | ----------------------------------------------------------------------- |
| scannerViewId    | String: The view provided by the application, used for UI customization |
| dvcID            | String (Optional): DvcID                                                |
| mobileSessionId  | String (Optional): random ID                                            |
| mobileDocumentId | String (Optional): random ID                                            |

b. **Verify Enrolled LiveID** – Use the following command to verify the enrolled liveID.

```dart
await _blockidpluginPlugin.verifyLiveIDScanning(
        scannerViewId,
        dvcID: const_dvcID, // this param is optional, can be omitted
        mobileSessionId: random_UUID, // optional param
        mobileDocumentId: "liveid_$random_UUID", // optional param
        ); 
```

**Method Summary**

| Parameter        | Description                                                         |
| ---------------- | ------------------------------------------------------------------- |
| scannerViewId    | String: View provided by the application, used for UI customization |
| dvcID            | (Optional) String: DvcID                                            |
| mobileSessionId  | (Optional) String: random ID                                        |
| mobileDocumentId | (Optional) String: random ID                                        |

c. **Check if LiveID is registered** – Use the following sample command to check if the liveID has been registered.

```dart
final status = await _blockidpluginPlugin.isLiveIDRegistered();
```

The status will be a boolean value indicating whether the LiveID is registered.

d. **Stop LiveID Scanning** – Use the following sample command to stop the liveID scanning process.

```dart
final status = await _blockidpluginPlugin.stopLiveIDScanning();
```

The status will be a boolean value indicating whether scanning has been stopped.

e. **LiveID Scanning responses** – Displays the responses of the liveID scanning.

| Response                 | Description                                                                                                                                                                   |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FocusOnFaceChanged       | When the user's face focus changes within the scanner focus area.                                                                                                             |
| faceLivenessCheckStarted | When the LiveID scanner started the liveness check.                                                                                                                           |
| completed                | When the LiveID Scanning is completed.                                                                                                                                        |
| failed                   | When the LiveID Scanning fails. This will give the error object as follows: **Error**: ErrorResponse which will have the code. **Error Code Description**: Error Description. |

#### **Document Enrollment**

You can use this functionality to enroll different types of documents such as Driver's Licenses, Passports, and National IDs.

a. **Scanning document** – Use the following command to scan the document.

```dart
final documentStr = await _blockidpluginPlugin.scanDocument(type);
```

Where the `documentStr` provides a JSON string containing document information, and its types are listed below:

| Type           | Description    |
| -------------- | -------------- |
| nationalID     | National ID    |
| drivingLicense | Driver License |
| passport       | Passport       |

b. **Registering Document** – Use the following sample command to register the document.

```dart
// This will register Drivers License with LiveID
final status =
          await _blockidpluginPlugin.registerDrivingLicenceWithLiveID(response,
              mobileSessionId: generatedUUID,
              mobileDocumentId: "dl_with_liveid_$generatedUUID",
              );

// This will register Passport with LiveID
final status = await _blockidpluginPlugin.registerPassportWithLiveID(
          response,
          mobileSessionId: generatedUUID,
          mobileDocumentId: "ppt_with_liveid_$generatedUUID",
          );

// This will register National ID with LiveID
final status = await _blockidpluginPlugin.registerNationalIDWithLiveID(
          response,
          mobileSessionId: generatedUUID,
          mobileDocumentId: "nationalid_with_liveid_$generatedUUID",
          );
```

**Method Summary**

| Parameter        | Description                                                        |
| ---------------- | ------------------------------------------------------------------ |
| response         | Type: DocumentScannerResponse (refer `blockidplugin_wrapper.dart`) |
| mobileSessionId  | (Optional) String: random ID                                       |
| mobileDocumentId | (Optional) String: random ID                                       |

#### **QR Scanning**

The following functions help with QR scanning.

a. **Start Scan** - To start the scanning process, use the following command:

```dart
final qrDataString = await _blockidpluginPlugin.startQRScanning(
    scannerViewId,
);
```

**Method Summary**

| Parameter     | Description                                                         |
| ------------- | ------------------------------------------------------------------- |
| scannerViewId | String: View provided by the application, used for UI customization |
| return        | qrDataString: Scanned data as String                                |

b. **Stop Scan** - To stop the scanning process, use the following command:

```dart
await _blockidpluginPlugin.stopQRScanning();
```

**Method Summary**

| Parameter | Description                                                      |
| --------- | ---------------------------------------------------------------- |
| return    | Boolean: It will return true if the scanning process is stopped. |

#### **Locking and Unlocking SDK**

The SDK's lock and unlock functionality controls feature access, ensuring SDK capabilities are accessible only when explicitly unlocked.

{% hint style="info" %}
Note:

By default, the BlockID SDK is locked. To access its functionalities, you must first unlock the SDK. You can unlock it using one of the following methods:

* Scan your Biometric data to unlock the SDK. For more information, see Biometric Enrollment.
* Alternatively, use the unlock functionality to gain access and continue using BlockID features.
  {% endhint %}

To lock the SDK, run the following command:

```dart
await _blockidpluginPlugin.lockSDK();
```

To unlock the SDK, run the following command:

```dart
await _blockidpluginPlugin.unLockSDK();
```

#### **Resetting SDK**

Use this function to purge the SDK wallet and remove all data stored or owned by the SDK.

To reset the SDK, run the following sample command:

```dart
await _blockidpluginPlugin.resetSDK(
        AppConstants.tag,
        AppConstants.community,
        AppConstants.dns,
        AppConstants.licenseKey,
      );
```

Here, the parameters passed to the function are predefined and should be included in the app as configuration properties.

### **Frequently Asked Questions**

**Q. Can I remove the LiveID option from SDK?**

A. No, you cannot remove the LiveID option. To remove it, contact our support team.

**Q. What should I do if I do not have the `pod file` in the iOS directory?**

A. You can run the `pod init` command in the terminal. This command will initialize a Podfile for your project.

**Q. How do I seek the version of the BlockID SDK?**

A. You can use the **getSDKVersion()** function in your dart class, as shown below, to retrieve the version of BlockID SDK.

```dart
Future<void> getSDKVersion() async {
    String response = "";
    try {
        final String result = await methodChannel.invokeMethod('getSDKVersion');
        response = result;
    } on PlatformException catch (e) {
        response = "Failed to Invoke: '${e.message}'.";
    }
    setState(() {
        _sdkVersion = response;
    });
}
```

```
```

### Overview

```
Flutter is an open-source UI software development kit created by Google. It is designed to build natively compiled applications for mobile, web, and desktop from a single codebase. It uses the Dart programming language and provides a rich set of pre-designed widgets and tools that allow developers to create highly customizable, expressive, and fast-performing interfaces. 

The BlockID SDK is a cross-platform dependency compatible with both Android and iOS. It can be effortlessly integrated into native Android applications using Gradle as the dependency management tool, while iOS applications can incorporate it using CocoaPods.  

Here are the key features of the BlockID SDK: 
```

```ruby
Post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|

      # set build library for distribution to true
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'

      # set iOS Deployment Target to 16.0
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'

      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        'PERMISSION_CAMERA=1'
      ]
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end
```

4. Save the `Podfile` and run the `pod install` command to install the specified pods.

#### **Configuring Android Directory**

To configure the files inside the Android directory of your Flutter project, follow these steps:

**Step 1**: Adding Repositories

Navigate to the `<project>/android/app/build.gradle` file and make the following changes under the **allprojects > repositories** section.

```groovy
allprojects {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
        maven {
            url 'https://artifactory.1kosmos.net/artifactory/maven-releases-local/'
            credentials {
                username = 'developer'
                password = 'q5k#06ZcjSo#'
            }
        }
        maven { url "https://jitpack.io" }
    }
}
```

Also add AGP version enforcement for subprojects:

```groovy
subprojects { subproject ->
    subproject.buildscript {
        configurations.configureEach {
            resolutionStrategy {
                eachDependency { details ->
                    if (details.requested.group == 'com.android.tools.build' && details.requested.name == 'gradle') {
                        details.useVersion '9.0.0'
                    }
                }
            }
        }
    }
}
```

`android/settings.gradle`

Ensure AGP 9.0.0 is specified:

```groovy
plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "9.0.0" apply false
}
```

`android/gradle/wrapper/gradle-wrapper.properties`

Ensure Gradle 9.3.1:

```
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
```

**Step 2**: Modify the Gradle build configurations

1. Specify the `minSdkVersion` property to 28 and set the Java compatibility to Java 17.

```groovy
android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlin {
        compilerOptions {
            jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
        }
    }

    defaultConfig {
        minSdkVersion 28
    }
}
```

2. Add packaging options using the new DSL.

```groovy
android {
    packagingOptions {
        jniLibs {
            excludes += [
                'lib/x86_64/freebsd/libscrypt.so',
                'lib/x86_64/linux/libscrypt.so',
                'lib/x86_64/darwin/libscrypt.dylib'
            ]
        }
        resources {
            excludes += [
                'META-INF/rxjava.properties',
                'AndroidManifest.xml',
                'META-INF/INDEX.LIST',
                'META-INF/LICENSE.md',
                'META-INF/DEPENDENCIES',
                'META-INF/NOTICE.md',
                'META-INF/FastDoubleParser-LICENSE',
                'META-INF/FastDoubleParser-NOTICE',
                'META-INF/io.netty.versions.properties',
                'META-INF/DISCLAIMER',
                'META-INF/*.SF',
                'META-INF/*.DSA',
                'META-INF/*.RSA',
                'META-INF/MANIFEST.MF'
            ]
        }
    }
}
```

3. Add the following configurations to the root-level build. gradlegradle file.

```groovy
configurations.configureEach {
    resolutionStrategy {
        force 'androidx.test.espresso:espresso-core:3.6.1'
        force 'androidx.test.espresso:espresso-idling-resource:3.6.1'
    }
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'org.bouncycastle') {
            details.useVersion '1.84'
        }
    }
}
```

**Step 3**: Add Permissions to the **AndroidManifest.xml** file.

The BlockID SDK requires the following permissions. Add them to your **AndroidManifest.xml** file by navigating to the `[project]/android/app/src/debug` folder.

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:label="appname"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/LaunchTheme"
        android:allowBackup="true"
        tools:replace="android:allowBackup,android:theme,android:label"/>
</manifest>
```

**Step 4**: Run the Flutter project.

### **Importing flutter\_blockidplugin to your Project**

To seamlessly use the BlockID app's functionality, run the following command to import the blockidplugin into your Flutter project.

```dart
import 'package:flutter_blockidplugin/index.dart';
```

**Sample**

```dart
final _blockidpluginPlugin = Blockidplugin();
await _blockidpluginPlugin.setLicenseKey(YOUR_KEY);
```

### **Managing Functionalities in the Sample Project**

After creating the sample project, the following BlockID app functionalities can be explored in the Flutter Android/iOS applications:

* SDK Setup functions
* Get DID
* Get Version
* Biometric Enrollment
* Biometric Verification
* Create a one-time passcode
* LiveID Enrollment
* LiveID Verification
* Document Enrollment
* Login with a QR Code
* Locking and Unlocking SDK
* Resetting SDK

#### **SDK Setup functions**

You can set up an SDK to manage the license key, wallet, and tenant. The following table provides information on various SDK functions:

| Function          | Description                                     | Container                                                                                           |
| ----------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| Set License Key   | Set the license key to access the blockidplugin | `await _blockidpluginPlugin.setLicenseKey(const_licenseKey);`                                       |
| Initialize Wallet | Create a wallet for the application             | `final status = await _blockidpluginPlugin.initiateTempWallet();`                                   |
| Register Tenant   | Register the tenant with the SDK                | `final status = await _blockidpluginPlugin.registerTenant(const_tag, const_community, const_dns,);` |

#### **Get DID**

To retrieve the unique Distributed IDentifier (DID) of the application, run the following command. Its response is displayed as a String.

```dart
final response = await _blockidpluginPlugin.getDID();
// response will have DID as String
```

#### **Get Version**

To retrieve the version of the currently used BlockID SDK, run the following command.

```dart
final response = await _blockidpluginPlugin.blockIDSDKVersion();
```

#### **Biometric Details**

Use this functionality to scan your biometric data to unlock the BlockID SDK and gain access to its functionality.

To enroll a biometric, run the following command:

```dart
final status = await _blockidpluginPlugin.enrollDeviceAuth();
```

To verify if any biometric data has already been enrolled, run the following command:

```dart
final status = await _blockidpluginPlugin.verifyDeviceAuth();
```

To check if the biometric has been registered, run the following command:

```dart
final status = await _blockidpluginPlugin.isDeviceAuthRegistered();
```

#### **One-time passcode**

Obtain the time-based OTP from the blockidplugin by running the following command:

```dart
final response = await _blockidpluginPlugin.totp();
```

Its response will be of the type TOTP and provide the following objects:

| Parameter        | Description                                                                                           |
| ---------------- | ----------------------------------------------------------------------------------------------------- |
| totp             | String: Displays a time-based one-time password (OTP).                                                |
| getRemainingSecs | Int: Displays the time after which the OTP expires. The default expiry time of the OTP is 30 seconds. |

#### **LiveID Enrollment**

You can perform the following functions during the enrollment of liveID:

a. **Enroll LiveID** – Use the following command to enroll the liveid.

```dart
await _blockidpluginPlugin.enrollLiveIDScanning(
        scannerViewId,
        dvcID: const_dvcID, // this param is optional, can be omitted
        mobileSessionId: random_UUID, // optional param
        mobileDocumentId: "liveid_$random_UUID", // optional param
        ); 
```

**Method Summary**

| Parameter        | Description                                                             |
| ---------------- | ----------------------------------------------------------------------- |
| scannerViewId    | String: The view provided by the application, used for UI customization |
| dvcID            | String (Optional): DvcID                                                |
| mobileSessionId  | String (Optional): random ID                                            |
| mobileDocumentId | String (Optional): random ID                                            |

b. **Verify Enrolled LiveID** – Use the following command to verify the enrolled liveID.

```dart
await _blockidpluginPlugin.verifyLiveIDScanning(
        scannerViewId,
        dvcID: const_dvcID, // this param is optional, can be omitted
        mobileSessionId: random_UUID, // optional param
        mobileDocumentId: "liveid_$random_UUID", // optional param
        ); 
```

**Method Summary**

| Parameter        | Description                                                         |
| ---------------- | ------------------------------------------------------------------- |
| scannerViewId    | String: View provided by the application, used for UI customization |
| dvcID            | (Optional) String: DvcID                                            |
| mobileSessionId  | (Optional) String: random ID                                        |
| mobileDocumentId | (Optional) String: random ID                                        |

c. **Check if LiveID is registered** – Use the following sample command to check if the liveID has been registered.

```dart
final status = await _blockidpluginPlugin.isLiveIDRegistered();
```

The status is a boolean indicating whether the LiveID is registered.

d. **Stop LiveID Scanning** – Use the following sample command to stop the liveID scanning process.

```dart
final status = await _blockidpluginPlugin.stopLiveIDScanning();
```

The status will be a boolean value indicating whether scanning has been stopped.

e. **LiveID Scanning responses** – Displays the responses of the liveID scanning.

| Response                 | Description                                                                                                                                                                   |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FocusOnFaceChanged       | When the user's face focus changes within the scanner focus area.                                                                                                             |
| faceLivenessCheckStarted | When the LiveID scanner started the liveness check.                                                                                                                           |
| completed                | When the LiveID Scanning is completed.                                                                                                                                        |
| failed                   | When the LiveID Scanning fails. This will give the error object as follows: **Error**: ErrorResponse which will have the code. **Error Code Description**: Error Description. |

#### **Document Enrollment**

You can use this functionality to enroll different types of documents such as Driver's Licenses, Passports, and National IDs.

a. **Scanning document** – Use the following command to scan the document.

```dart
final documentStr = await _blockidpluginPlugin.scanDocument(type);
```

Where the `documentStr` provides a JSON string containing document information, and its types are listed below:

| Type           | Description    |
| -------------- | -------------- |
| nationalID     | National ID    |
| drivingLicense | Driver License |
| passport       | Passport       |

b. **Registering Document** – Use the following sample command to register the document.

```dart
// This will register Drivers License with LiveID
final status =
          await _blockidpluginPlugin.registerDrivingLicenceWithLiveID(response,
              mobileSessionId: generatedUUID,
              mobileDocumentId: "dl_with_liveid_$generatedUUID",
              );

// This will register Passport with LiveID
final status = await _blockidpluginPlugin.registerPassportWithLiveID(
          response,
          mobileSessionId: generatedUUID,
          mobileDocumentId: "ppt_with_liveid_$generatedUUID",
          );

// This will register National ID with LiveID
final status = await _blockidpluginPlugin.registerNationalIDWithLiveID(
          response,
          mobileSessionId: generatedUUID,
          mobileDocumentId: "nationalid_with_liveid_$generatedUUID",
          );
```

**Method Summary**

| Parameter        | Description                                                        |
| ---------------- | ------------------------------------------------------------------ |
| response         | Type: DocumentScannerResponse (refer `blockidplugin_wrapper.dart`) |
| mobileSessionId  | (Optional) String: random ID                                       |
| mobileDocumentId | (Optional) String: random ID                                       |

#### **QR Scanning**

The following functions help with QR scanning.

a. **Start Scan** - To start the scanning process, use the following command:

```dart
final qrDataString = await _blockidpluginPlugin.startQRScanning(
    scannerViewId,
);
```

**Method Summary**

| Parameter     | Description                                                         |
| ------------- | ------------------------------------------------------------------- |
| scannerViewId | String: View provided by the application, used for UI customization |
| return        | qrDataString: Scanned data as String                                |

b. **Stop Scan** - To stop the scanning process, use the following command:

```dart
await _blockidpluginPlugin.stopQRScanning();
```

**Method Summary**

| Parameter | Description                                                      |
| --------- | ---------------------------------------------------------------- |
| return    | Boolean: It will return true if the scanning process is stopped. |

#### **Locking and Unlocking SDK**

The SDK's lock and unlock functionality controls feature access, ensuring SDK capabilities are accessible only when explicitly unlocked.

:::note By default, the BlockID SDK is locked. To access its functionalities, you must first unlock the SDK. You can unlock it using one of the following methods:

* Scan your Biometric data to unlock the SDK. For more information, see Biometric Enrollment.
* Alternatively, use the unlock functionality to gain access and continue using BlockID features. :::

To lock the SDK, run the following command:

```dart
await _blockidpluginPlugin.lockSDK();
```

To unlock the SDK, run the following command:

```dart
await _blockidpluginPlugin.unLockSDK();
```

#### **Resetting SDK**

Use this function to purge the SDK wallet and remove all data stored or owned by the SDK.

To reset the SDK, run the following sample command:

```dart
await _blockidpluginPlugin.resetSDK(
        AppConstants.tag,
        AppConstants.community,
        AppConstants.dns,
        AppConstants.licenseKey,
      );
```

Here, the parameters passed to the function are predefined and should be included in the app as configuration properties.

### **Frequently Asked Questions**

**Q. Can I remove the LiveID option from SDK?**

A. No, you cannot remove the LiveID option. To remove it, contact our support team.

**Q. What should I do if I do not have the `pod file` in the iOS directory?**

A. You can run the `pod init` command in the terminal. This command will initialize a Podfile for your project.

**Q. How do I check the version of the BlockID SDK?**

A. You can use the getSDKVersion() function in your Dart class, as shown below, to retrieve the version of the BlockID SDK.

```dart
Future<void> getSDKVersion() async {
    String response = "";
    try {
        final String result = await methodChannel.invokeMethod('getSDKVersion');
        response = result;
    } on PlatformException catch (e) {
        response = "Failed to Invoke: '${e.message}'.";
    }
    setState(() {
        _sdkVersion = response;
    });
}
```

```
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.1kosmos.com/mobile-sdk/flutter-integration-guide.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
