Flutter SDK Integration Guide

Welcome to the Flutter SDK integration guide. Follow these steps to seamlessly integrate our Digital Identity solution through our Flutter SDK for secure and efficient validation of your users by identity flows.

Prerequisites

  1. Account Creation: In order to perform an integration in any of our services, you must have a Truora account. Your Truora sales representative will provide you with one. To log into your existing account, go to https://account.truora.com/#/auth/login.

  2. Create a Truora API Key: In order to perform an integration in any of our services, you must have a Truora API key. Follow this guide to create your Truora API key.

  3. Create a Digital Identity Web Flow: For instructions on how to create a Web Flow, please refer to the Digital Identity Verification Flow guide.

  4. Create a Web Integration Token: For instructions on how to generate a token, please refer to the How to create a Web Integration Token guide.


Flutter SDK Documentation

Truora provides a Flutter plugin that simplifies the integration of our Digital Identity (DI) solution into your applications. This package offers the necessary classes and protocols to initiate identity verification processes and efficiently manage the results.

Setup

Integrating the Truora SDK into a Flutter project is quick and straightforward. It is available for installation via pub.dev for easy setup. For more information, visit the Truora SDK for Flutter project.

  1. Create a new Flutter project by running the following command:

    Create App
    
          flutter create MyApp
       

  2. Add the Truora SDK dependency. Navigate to the project directory and add the Truora SDK dependency:

    Add Dependency
    
          cd MyApp
          flutter pub add truora_sdk
       


iOS Configuration

To properly configure your iOS application, make the following adjustments:

  1. Modify info.plist:

Add the necessary permissions based on the verifications you will use:

  • For camera verifications, add:

    Camera Verifications
    
          <key>NSCameraUsageDescription</key>
          <string>We need access to your camera for identity verification.</string>
         

  • For geolocation verifications, add:

    Geolocation Verifications
    
          <key>NSLocationWhenInUseUsageDescription</key>
          <string>We need access to your location for verification.</string>
         

  • For document verification that requires uploading files from the gallery, add:

    Document Verifications
    
          <key>NSPhotoLibraryUsageDescription</key>
          <string>We need access to your gallery for document verification.</string>
         

  1. Update Podfile:

In your ios/Podfile, include the following code to manage permissions:

iOS

        post_install do |installer|
        installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        
            target.build_configurations.each do |config|
              config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
                '$(inherited)',
                'PERMISSION_CAMERA=1',
                'PERMISSION_PHOTOS=1',
                'PERMISSION_LOCATION=1',
              ]
            end
        end
        end
    

Note: Only add the permissions that your application will use.

  1. Update Pods:

Run the following command to update your pods:

Update Pods

     cd ios && pod install
   

Android Configuration

To configure your Android application, modify AndroidManifest.xml by adding the necessary permissions:

  1. Camera Verification:

    Camera Verification
    
         <uses-feature android:name="android.hardware.camera" android:required="true" />
         <uses-permission android:name="android.permission.CAMERA" />
       

  2. Geolocation Verification:

    Geolocation Verification
    
         <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
         <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
       

  3. Document Verification (Gallery Upload):

    Document Verification
    
         <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
       

How to Use

In your build() method, configure the TruoraSDK widget with the necessary properties:

  • token: This is the API token used to authorize and start the identity verification process.
  • requiredPermissions: A list of permissions that the SDK requires. Possible permissions include:
    • TruoraPermission.camera: Access to the camera for identity verification.
    • TruoraPermission.location: Access to location for geolocation verification.
    • TruoraPermission.photos: Access to the gallery for document verification.

Callback Functions

The TruoraSDK allows you to handle various events:

  • onError: Triggered if an error occurs during the process.
  • onStepsCompleted: Invoked once the identity verification steps are completed.
  • onProcessSucceeded: Triggered if the identity verification is successful.
  • onProcessFailed: Called if the identity verification fails.

Example Code

Here’s an example of how to implement the TruoraSDK in your widget:

Android

    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: TruoraSDK(
          token: 'Replace this with your process token',
    
          // Add needed permissions for the process
          requiredPermissions: const [
            TruoraPermission.camera,
            TruoraPermission.location,
          ],
    
          onError: (errorMessage) {
            _showErrorDialog(context, errorMessage);
          },
    
          onStepsCompleted: (processID) {
            _navigateToResultsPage('completed', processID, context);
          },
    
          onProcessSucceeded: (processID) {
            _navigateToResultsPage('success', processID, context);
          },
    
          onProcessFailed: (processID) {
            _navigateToResultsPage('failure', processID, context);
          },
        ),
      );
    }


Example Application

You can review our sample Flutter application, which serves as a comprehensive guide for utilizing the SDK, at the following link: