nashid_io 0.0.5

SDKflutter
Platformandroidios

The nashid_io Flutter plugin provides an interface to integrate the Nashid SDK into your application for document scanning and verification purposes.

This package is deprecated. Please use NashidVerifySdk instead.

Nashid IO Flutter Plugin

The nashid_io Flutter plugin provides an interface to integrate the Nashid SDK into your application for document scanning and verification purposes.


Features

  • Scan Oman ID and Passport documents.
  • Initialize the Nashid SDK with easy setup.
  • Retrieve document verification data effortlessly.
  • Built-in error handling for connectivity and backend issues.

Installation

  1. Add the plugin to your pubspec.yaml file:
    dependencies:
      nashid_io: ^latest_version
    
    
    
  2. Import the plugin in your Dart code:
    import 'package:nashid_io/nashid_io.dart';
    

Setup Instructions

IOS Configuration

  1. Add the following permission to your Info.plist file:

    <key>NSCameraUsageDescription</key>
    <string>We need access to the camera to scan documents</string>
    
    <key>Privacy - NFC Scan Usage Descriptione</key>
    <string>Read NFC passport</string>
    
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>We need your location to provide this feature.</string>
    
    <key>NSLocationAlwaysUsageDescription</key>
    <string>We need your location to provide background features.</string>
    
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>We need your location to provide background and foreground features.</string>
    
  2. Update your Podfile:

    platform :ios, '13.0'
    
     post_install do |installer|
      installer.pods_project.targets.each do |target|
       flutter_additional_ios_build_settings(target)
       /// Add these lines
       target.build_configurations.each do |config|
         config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
         config.build_settings['OTHER_SWIFT_FLAGS'] = '-no-verify-emitted-module-interface'
         config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
         config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
       end
     end
    
  3. Enable NFC Capability

    • To ensure the proper functionality of the SDK, you need to enable the Near Field Communication Tag Reading capability in your project.
    • Open your project in Xcode.
    • Navigate to your Target settings.
    • Go to the Signing & Capabilities tab.
    • Click the + Capability button.
    • Select Near Field Communication Tag Reading from the list.
  4. Set Privacy Usage Description for NFC

    • In Xcode, go to the Build Settings tab.
    • Search for Privacy - NFC Scan Usage Description.
    • Double-click the field and add the following string: "Read NFC passport"
  5. Add the following script in Build Phases > Run Script:

-    cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Frameworks/NewVerifySDK.ramework/"
  if [[ -d "Frameworks" ]]; then
      rm -fr Frameworks
  fi

Android Configuration

  1. In the tag of AndroidManifest.xml, add:

     /// Add this attribute to the <manifest> tag
     xmlns:tools="http://schemas.android.com/tools" 
     /// Add this attribute to the <application> tag
     tools:replace="android:name"
     android:enableOnBackInvokedCallback="true"
    
  2. Add these permissions

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

Usage

Step 1: Initialize the Plugin

  1. Start by creating an instance of the plugin:
     final _nashidIoPlugin = NashidIo();
    

Step 2: Generate SDK Keys

  1. Contact Nashid support to obtain your SDK Key and SDK Secret Key.

Main Functions

  1. Initialize the SDK
    • String (2 letters): Language (default = en (English))
     String? response = await _nashidIoPlugin.initialize(
         "<your-sdk-key>",
         "<your-sdk-secret-key>",
         "en",
          );
     var decodedResponse = jsonDecode(response!);
    
  • Example decodedResponse:
    • Response Success: { "result": true, "errorMessage": "" }

    • Response Error: { "result": false, "errorMessage": "Error message" }

  1. Scan Document

     String? response = await _nashidIoPlugin.scanDocument(
      ofType: 1,
     );
     var decodedResponse = jsonDecode(response!);
    
    
    • ofType Values:

      • 1 for Oman ID.
      • 2 for Passport.
    • Response Success: { "result": true, "errorMessage": "", "verificationId": "Verification ID" }

    • Response Error: { "result": false, "errorMessage": "Error Message", "verificationId": "" }

  2. Get Verification Data

     String? response = await _nashidIoPlugin.getVerificationData(
      verificationId: "Verification ID",
      var decodedResponse = jsonDecode(response!);
      var scanDataResponse;
      if(Platform.isIOS){
        scanDataResponse=decodedResponse['scanData'];
      }else{
        scanDataResponse=jsonDecode(decodedResponse['scanData']);
      }
     );
    
    • Response Success: { "result": true, "errorMessage": "", "scanData": {} }

    • Response Error: { "result": false, "errorMessage": "Error Message", "scanData": null }

Error Handling

  • If the SDK is not initialized, the scanDocument and getVerificationData functions will return an error.
  • If the SDK is initialized successfully, the scanDocument function will return a verificationId, which can be used to retrieve the verification data using the getVerificationData unction.
  • If the scanDocument function fails, it will return an error message and an empty verificationId.
  • If the getVerificationData function fails, it will return an error message and null for the ScanData.
  • No Connectivity (Internet Issue):
  • errorMessage: "An error happened due to no connectivity, please try again later."
  • Backend Connectivity Issue:
  • errorMessage: "We’re experiencing an issue on our end, and our team is aware of it. A fix ill be available soon."

Supported Platforms

  • iOS: Version 13.0 and above.
  • Android: SDK 21 and above, Ensure required permission included.

-This plugin provides an efficient way to integrate Nashid's document scanning and verification features. For further assistance, contact Nashid's support team.