Ask AI

Android SDK Integration

Introduction

This document serves as a comprehensive guide for Android developers to seamlessly integrate Nashid Verify SDK 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.

Nashid Verify SDK is designed to streamline identity verification processes, ensuring a smooth integration experience across platforms.

Prerequisites

Android:

  • Android Studio Arctic Fox (2020.3.1) or higher
  • Minimum SDK version: 21 (Android 5.0)
  • Kotlin version: 1.9.24
  • Java Development Kit (JDK) 17
  • Gradle 8.0 or higher

Installation

Android:

  1. Add the Maven Central repository to your project's root build.gradle
    1. 	repositories {
        mavenCentral()
      }
  1. Add the SDK dependency to your app's build.gradle
    1. dependencies {
        // Nashid Verify SDK
        implementation 'io.nashid.verify:sdk:latest_version'
        // Koin Dependency Injection (Required)
        implementation 'io.insert-koin:koin-android:3.4.0'
      }
      Note: Koin is required for the SDK's dependency injection functionality. Make sure to use the specified version for compatibility.
  1. Initialize Koin in your Application class
    1. import nashid.verify.sdk.utils.KoinEnvironment
      class YourApplication : Application() {
          override fun onCreate() {
              super.onCreate()
              // Initialize Koin for dependency injection
              KoinEnvironment.initKoin(this)
          }
      }
  1. Update AndroidManifest.xml to use your Application class
    1. <application
          android:name=".YourApplication"
          ...
      >
  1. Ensure your app's build.gradle includes these configurations:
    1. android {
        compileSdk 34
        defaultConfig {
          minSdk 21
          targetSdk 34
        }
      }

Usage

1. Import Nashid Verify SDK:

Android:

// Add this to your build.gradle on module level with reference to latest version
implementation 'io.nashid.verify:sdk:x.y.z'
// Import dependencies in your project for usage in any class
import nashid.verify.sdk.VerifySDKManager;

2. Initialize Nashid Verify SDK:

To start using the SDK, you need to create an SDK Application and configure the desired verification flow via your admin dashboard.

The initialize() function expects the following arguments:

  1. SDK Application Key (Mandatory): The key generated using your Nashid Verify admin dashboard.
  1. SDK Application Key Secret (Mandatory): The key secret generated using your Nashid Verify admin dashboard.
  1. Language Code (Optional): en for English (default), ar for Arabic ..etc.
  1. Extra Data (Optional): An object of key-value pairs that you can use to annotate the verification data generated with additional data that your consumer application may need.

The initialize() function returns a value, indicating whether initialization was successful (true) or unsuccessful (false), along with an error message in case of unsuccessful initialization.

Android:

VerifySDKManager.getInstance().initialize(
  sdkKey: "YOUR_SDK_KEY",
  sdkSecretKey: "YOUR_SECRET_KEY",
  languageId: "en"
);

3. Verify A Document Using Nashid Verify SDK

Once Nashid Verify SDK is initialized successfully, you can start verifications journeys for your users using the verify() function.

This function expects an input argument specifying the type of document to be verified (for now Omani ID or International Passport).

And as a result of the verification flow it returns three values:

  1. Result: A boolean flag that is true when the verification flow is successful, and false other wise.
  1. Error Message: A string contains the error details in case of unsuccessful verification.
  1. Verification ID: An ID of the created verification. This ID can be used later on to get the results collected with any additional checks/information annotated by backend services.

Example1: Verify With Omani ID

Android:

VerifySDKManager.getInstance().verify(DocumentType.OMAN_ID);

Example1: Verify With International Passport

Android:

VerifySDKManager.getInstance().verify(DocumentType.Passport);

4. Using Nashid Verify SDK To Get A Verification Result

Once you have a valid verification ID as an outcome of a successful verification journey you can use getVerificationResult() function to get the results collected with any additional checks/information annotated by backend services using the verification ID.

Example: Retrieve the data of verification ID abcd1234

Android:

val scanResults = VerifySDKManager.getInstance().getVerificationResult(
  verificationID: "abcd1234"
);
  • The verificationID (abcd1234) is just an example value that represents what we get as a result of the verify functionality.
  • Example Response:
    • {
          "data": {
              "id": "abcd1234",
              "created_at": "2025-01-14T09:44:39.051016+00:00",
              "updated_at": "2025-01-14T09:45:33.344098+00:00",
              "updated_by": null,
              "data": {
                  "NFC": {
                      "name": "John Doe",
                      "title": "Mr.",
                      "gender": "Male",
                      "address": "123 Elm Street",
                      "telephone": "123-456-7890",
                      "issue_date": "2024-01-01",
                      "profession": "Software Engineer",
                      "tb_numbers": "TB12345",
                      "custody_info": "No",
                      "expiry_date": "2030-01-01",
                      "permit_type": "Work",
                      "use_by_date": "2030-12-31",
                      "visa_number": "V123456",
                      "date_of_birth": "1990-05-15",
                      "document_type": "Passport",
                      "id_card_number": "ID123456",
                      "place_of_birth": "City A",
                      "rsa_public_key": "XYZ123",
                      "issuing_country": "USA",
                      "passport_number": "P12345678",
                      "personal_number": "987654321",
                      "gender_arabic": "ذكر",
                      "permit_number": "Permit123",
                      "gender_english": "Male",
                      "identity_number": "ID123",
                      "full_name_arabic": "جون دو",
                      "full_name_english": "John Doe",
                      "nationality_arabic": "أمريكي",
                      "company_name_arabic": "شركة البرمجيات",
                      "nationality_english": "American",
                      "company_name_english": "Software Company",
                      "place_of_issue_arabic": "مدينة ب",
                      "company_address_arabic": "123 شارع النخيل",
                      "place_of_issue_english": "City B",
                      "country_of_birth_arabic": "الولايات المتحدة",
                      "country_of_birth_english": "United States",
                      "ecdsa_public_key": "ABC456",
                      "personal_summary": "Experienced software engineer.",
                      "issuing_authority": "Government Authority",
                      "passport_expiry_date": "2030-01-01",
                      "proof_of_citizenship": "Yes",
                      "security_information": "Secure",
                      "active_authentication_passed": "Yes",
                      "issuer_digital_signature_verification": "Passed"
                  },
                  "scan": {
                      "gender": "Male",
                      "country": "USA",
                      "mrz_text": "MRZ123456",
                      "full_name": "John Doe",
                      "document_no": "DOC12345",
                      "nationality": "American",
                      "date_of_birth": "1990-05-15",
                      "document_type": "Passport",
                      "expiry_date": "2030-01-01"
                  },
                  "liveness": {
                      "passive_liveness_confirmed": false,
                      "active_liveness_confirmed": true
                  }
              },
              "metadata": {
                  "location": {
                      "latitude": 37.7749,
                      "longitude": -122.4194
                  },
                  "extradata": null,
                  "timestamp": "2024-58-22 08:58:52",
                  "device_ipv4": "0.0.0.0",
                  "device_ipv6": "fe80::4cc0:34ff:fe60:cc21",
                  "device_type": "SM-G996B",
                  "system_name": "Android",
                  "system_version": "13",
                  "device_identifier": "samsung_SM-G996B"
              },
              "artifacts": {
                  "liveness_image": "https://xxxxx.yyyyy/xxx.png",
                  "ocr_face_image": "https://xxxxx.yyyyy/yyy.png",
                  "back_side_image": "https://xxxxx.yyyyy/zzz.png",
                  "front_side_image": "https://xxxxx.yyyyy/aaaa.png",
                  "livness_image_without_bg": "https://xxxxx.yyyyy/abcd.png"
              },
              "annotations": {
                  "face_matching": {
                      "mode": "ocr",
                      "notes": "",
                      "is_successful": false,
                      "matching_score": 40,
                      "threshold_used": 53,
                      "nfc_matching_score": null,
                      "ocr_matching_score": 40
                  }
              },
              "type": {
                  "value": 1,
                  "title": "Omani ID"
              },
              "status": {
                  "value": 2,
                  "title": "Unsuccessful"
              }
          },
          "message": "Verification retrieved successfully.",
          "consolidated_message": "Verification retrieved successfully.",
          "details": {}
      }
Did this answer your question?
😞
😐
🤩

Last updated on February 1, 2025