QoreID Flutter SDK

πŸ“˜

Note

With this release (v1.0.7), customers can perform all Collection services like VeriFind (digital address verification), Passport, Driver's License and other QoreID services on both Android iOS platforms.

pub.dev Here is an example app

Installation

Using dart

dart pub add qoreidsdk

Using Flutter

 flutter pub add qoreidsdk

NOTE!! comment out #use_frameworks! in Podfile before installing cocoapods dependencies

//in your project directory

cd ios
pod install

Note: You are required to rebuild your application after installing the package.

Android

Add the following to your app/build.gradle

    //before your dependencies
repositories {
  mavenCentral()
  google()
  maven {
    url "https://repo.qoreid.com/repository/maven-releases/"
  }
  maven { url 'https://jitpack.io' }
}

Add this snippet of code to your app/proguard-rules.pro

-keep class com.qoreid.sdk.** { *; }
-dontshrink
-dontobfuscate
-dontoptimize

If you do not have the file in your ~/app/ directory, create one and add it to ~/app/gradle.build release configuration as shown below

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

import the library in MainActivity

import android.os.Bundle
import com.qoreid.qoreidsdk.QoreidsdkPlugin;

Add this snippet of code to your ~/com/example/<app name>/MainActivity

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        QoreidsdkPlugin.initialize(this);
    }

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        QoreidsdkPlugin.initialize(this)
    }

Permissions

Certain services on QoreID require device permissions to work properly. Follow the instructions here to add the required permissions to your ~/android/app/src/main/AndroidManifest.xml file.

Verifind required permissions

...
<!-- Required for Verifind --> 
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
...

iOS

Update your AppDelegate.m

QoreidSdK requires the UINavigationController to push a new ViewController to your app. To wrap your app's rootViewController in a UINavigationController. Update your AppDelegate with the following code snippet.

//Runner/AppDelegate.swift
import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    var navigationController: UINavigationController!
       
       override func application(_ application: UIApplication,
                               didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         
         
           let controller = window?.rootViewController as! FlutterViewController
           
           GeneratedPluginRegistrant.register(with: self)
           
           // create and then add a new UINavigationController
           self.navigationController = UINavigationController(rootViewController: controller)

           self.navigationController.setNavigationBarHidden(true, animated: false)
           self.window = UIWindow(frame: UIScreen.main.bounds);
           self.window.rootViewController = self.navigationController;
           self.window.makeKeyAndVisible();
        
           return super.application(application, didFinishLaunchingWithOptions: launchOptions)
       }

}

Permissions

Added the following to your ~/ios/<app name>/Info.plist file

...
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We need access to your location to provide you with location-based services, even when the app is in the background.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need access to your location while you are using the app to provide you with location-based services.</string>
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to take photos for profile pictures.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to allow you to select and upload images.</string>
...

If you have use_framework! enabled in your Podfile

Update Podfile (if you have use_framework! enabled)

 # REST OF YOUR CODE
...
target 'Your Target' do
  
  use_frameworks!

  
  # REST OF YOUR CODE
  

  # Add the following to add qoreidsdk (or other static frameworks) as a static library
  
  $static_framework = ['qoreidsdk']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
      end
  end
end
...
# REST OF YOUR CODE

Usage: Example

import 'package:flutter/material.dart';
import 'package:qoreidsdk/qoreidsdk.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    _qoreidsdkResult();
  }

  void _qoreidsdkResult() async {
    Qoreidsdk.onResult((result) async {
      print(result); //{code: E_USER_CANCELED, data: ResultData(customerReference=cus-ref, flowId="543", verification=null, productCode=face_verification), message: User canceled}
      
      //handle in success case e.g use verification ID
      if (data["data"] != null) {
        print(data["data"]["verification"]["id"]);
      }
    });
  }

  void _launchQoreid() async {
    // Launch Qoreid app
    QoreidData data = QoreidData(
        clientId: "", //required
        flowId: 0,
        customerReference: "cus-ref", //required
        productCode: "", //required required for collection
        addressData: {},
        applicantData: {},
        ocrAcceptedDocuments: "",
        identityData: {});
    await Qoreidsdk.launchQoreid(data);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Qoreidsdk Exampple',
            ),
            Container(
              padding: const EdgeInsets.all(20.0),
              width: double.infinity,
              child: ElevatedButton(
                onPressed: _launchQoreid,
                child: const Text('Launch QoreId'),
              ),
            )
          ],
        ),
      ),
    );
  }
}

Known Flutter Plugin Installation Issue (iOS)

If you are using XCode 15 and encounterErrno::ENOENT - No such file or directory @ rb_sysopen - ~dir/ios/Pods/Local Podspecs/qoreidsdk.podspec.json

Comment qoreidsdk in your .yaml file

Save the changes in .yaml file, run flutter pub get

cd into ios directory run pod install

Uncomment qoreidsdk in your .yaml file

run flutter pub get

cd ios/  &&  run pod install

flutter run. Your app should work now