nashid_verify_sdk 0.0.16
nashid_verify_sdk: ^0.0.16 copied to clipboard
The nashid_verify_sdk Flutter plugin provides an interface to integrate the Nashid SDK into your application for document scanning and verification purposes.
Flutter Implementation for Nashid Verification SDK (iOS & Android) #
Introduction #
This document serves as a comprehensive guide for Flutter developers to seamlessly integrate the VerifySDK into their applications. By following the step-by-step instructions provided, developers can simplify the process of scanning Oman ID cards and passports, and efficiently retrieve document scan results.
The VerifySDK is designed to streamline identity verification processes, ensuring a smooth integration experience across platforms.
Prerequisites #
Before you begin integrating the Nashid Verify SDK, ensure the following:
- Install the latest Flutter SDK.
- Install CocoaPods for iOS.
- Install Android Studio with SDK tools.
- Install Xcode(16.1 or higher) for iOS development.
- Run flutter doctor to verify the setup.
- Set up a real-device for testing.
- Use an IDE like Android Studio or VS Code with Flutter and Dart plugins.
- Run flutter pub get to fetch plugin dependencies.
Supported Platforms #
- iOS: Version 15.0 and above.
- Android: SDK 21 and above.
Installation #
Run this command:
flutter pub add nashid_verify_sdk
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
dependencies:
nashid_verify_sdk: ^latest_version
IOS Configuration #
-
Add the following permission to your Info.plist file:
<key>NSCameraUsageDescription</key> <string>We need access to the camera to scan documents</string> <key>NFCReaderUsageDescription</key> <string>NFC permission is required to complete the full KYC process.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>Location permission is required to complete the full KYC process.</string> <key>NSLocationAlwaysUsageDescription</key> <string>Location permission is required to complete the full KYC process.</string> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>Location permission is required to complete the full KYC process.</string> <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key> <array> <string>A000000018524F500101</string> <string>A0000002471001</string> <string>A0000002472001</string> <string>00000000000000</string> <string>A00000024300130000000101</string> <string>A0000002430013000000010109</string> <string>A000000243001300000001FF</string> </array> -
Update your Podfile:
platform :ios, '15.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 -
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.
-
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: "NFC permission is required to complete the full KYC process."
-
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
-
Run pod install
After modifying the Podfile, navigate to your ios directory and run the following command to install the required dependencies:
cd ios && pod install
Android Configuration #
-
Update AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <!--Add this line in manifest tag--> <!-- Add this attribute to the <application> tag --> tools:replace="android:name" android:enableOnBackInvokedCallback="true" -
Ensure your app's build.gradle include these configurations
android { compileSdk 34 defaultConfig { minSdk 21 targetSdk 34 }
Usage #
Step 1: Generate SDK Keys #
Use your Nashid Verify admin dashboard to set up the required SDK applications, then retrieve your SDK App Key and SDK App Secret. For more information please refer to Nashid Verify knowledge base
Step 2: Import the Framework #
import 'package:nashid_verify_sdk/nashid_verify_sdk.dart';
Step 3: Initialize the Plugin #
final _nashidIoPlugin = NashidVerifySdk();
Main Functions #
- Initialize the SDK
Map<String, dynamic> response = await _nashidIoPlugin.initialize( sdkKey: "<your-sdk-key>", sdkSecretKey: "<your-sdk-secret-key>", languageId:"en" );
-
Supported Languages
- languageId: default = en (English)
- languageId: ar (Arabic)
-
Example decodedResponse:
-
Response Success: { "result": true, "errorMessage": "" }
-
Response Error: { "result": false, "errorMessage": "Error message" }
-
-
Verify
// Oman ID Map<String, dynamic> response = _nashidIoPlugin.verify(ofType: 1); // Passport Map<String, dynamic> response = _nashidIoPlugin.verify(ofType: 2);-
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": "" }
-
-
Get Verification Result
Map<String, dynamic> response = await _nashidIoPlugin.getVerificationResult( verificationId: "ADDED_AS_STRING", );-
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 verify function will return a verificationID, which can be used to retrieve the verification data using the getVerificationResult function.
- If the scanDocument function fails, it will return an error message and an empty verificationID.
- If the getVerificationResult 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."