# Flutter Mobile SDK

Our in-house developed eNROLL platform serves as a technological compliance solution. A solution that is now familiarized across the globe in countries with big populations, where falsification of identity, signatures, and phishing is very common.

The software utilizes a set of AI-powered technologies, like the OCR (Optical Character Recognition), to cut back on the risks of human-based errors and the time needed for identification.

![App Screenshot](https://firebasestorage.googleapis.com/v0/b/excel-hr-app.appspot.com/o/Screenshot%202024-09-02%20at%2011.03.04%E2%80%AFAM.png?alt=media\&token=37acf293-9e0e-456c-8b7a-3b97c512d911)

![App Screenshot](https://firebasestorage.googleapis.com/v0/b/excel-hr-app.appspot.com/o/Screenshot%202024-09-02%20at%2011.03.28%E2%80%AFAM.png?alt=media\&token=1d5aafeb-ffe3-4faa-aa72-37b28f1810a9)

![App Screenshot](https://firebasestorage.googleapis.com/v0/b/excel-hr-app.appspot.com/o/Screenshot%202024-09-02%20at%2011.03.39%E2%80%AFAM.png?alt=media\&token=76489515-b21b-403f-a338-0f9889486b4b)

## REQUIREMENTS

* Minimum Flutter version 3.3.4
* Android minSdkVersion 24
* Kotlin Version 2.1.0
* iOS Deployment Target 13.0+

## 2. INSTALLATION

1- Run this command with Flutter:

```bash
$ flutter pub add enroll_plugin
```

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

```bash
dependencies:
  enroll_plugin: ^latest_version
```

* You can find the latest version here <https://pub.dev/packages/enroll\\_plugin/versions>

### 2.1. Android

* Add these lines to build.gradle file:

```bash
maven { url 'https://jitpack.io' }
maven { url = uri("https://maven.innovatrics.com/releases") }
```

* Upgrade minSdkVersion to 24 in app/build.gradle.
* Add the following lines to settings.gradle file:

```bash
buildscript {
    repositories {
        mavenCentral()
        maven {
            url = uri("https://storage.googleapis.com/r8-releases/raw")
        }
    }
    dependencies {
        classpath("com.android.tools:r8:8.2.24")
    }
}
```

### 2.2. iOS

* Add the following to your project info.plist file

```xml
<key>NSCameraUsageDescription</key>
<string>"Your Message to the users"</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>"Your Message to the users"</string>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
```

* Add these two sources to the iOS project Podfile

```bash
source 'https://github.com/innovatrics/innovatrics-podspecs'
source 'https://github.com/LuminSoft/eNROLL-iOS-specs'
source 'https://github.com/CocoaPods/Specs.git'
```

### 2.3. Add a license file to your project:

* For Android

![App Screenshot](https://firebasestorage.googleapis.com/v0/b/excel-hr-app.appspot.com/o/lic_android.png?alt=media\&token=9a6556c1-cea1-4fce-b073-0dba76bedf8f)

* For iOS

![App Screenshot](https://firebasestorage.googleapis.com/v0/b/excel-hr-app.appspot.com/o/lic_ios.webp?alt=media\&token=c4bcf3d8-d9d2-4c99-9a62-97349ff30fac)

ℹ️ Make sure your iOS project has a reference for the license file or instead:

* open iOS project
* Drag and drop the license file to the root folder of the project as described above
* make sure to copy items if needed, check the box is checked
* then done

### 2.4. Run Command line:

```bash
flutter pub get
```

## 3. IMPORT

```dart
import 'package:enroll_plugin/enroll_plugin.dart';
```

## 4. USAGE

* Create a widget and just return the EnrollPlugin widget in the build function as:

```dart
return EnrollPlugin(
    mainScreenContext: context,
    tenantId: 'TENANT_ID',
    tenantSecret: 'TENANT_SECRET',
    enrollMode: EnrollMode.onboarding,
    enrollEnvironment: EnrollEnvironment.staging,
    localizationCode: EnrollLocalizations.en,
    onSuccess: (applicantId) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        debugPrint("success: $applicantId");
      });
    },
    onError: (error) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        debugPrint("Error: ${error.toString()}");
      });
    },
    onGettingRequestId: (requestId) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        debugPrint("requestId:: $requestId");
      });
    },
    applicationId: 'APPLICATION_ID',
    levelOfTrustToken: 'LEVEL_OF_TRUST_TOKEN',
    googleApiKey: 'GOOGLE_API_KEY',
    correlationId: 'correlationId',
    requestId: 'requestId',
    skipTutorial: false,
    appColors: AppColors(
      primary: "#000000",
      secondary: "#FFFFFF",
      background: "#F8F8F8",
      successColor: "#4CAF50",
      warningColor: "#FFC107",
      errorColor: "#F44336",
      textColor: "#212121",
    ),
    enrollForcedDocumentType: EnrollForcedDocumentType.nationalIdOrPassport,
    templateId: 'templateId',
    contractParameters: 'contractParameters',
);
```

## 5. ENROLL MODES

The SDK supports **4 modes** defined in the `EnrollMode` enum:

```dart
enum EnrollMode {
  onboarding,
  auth,
  update,
  signContract
}
```

### Mode Details

| Mode           | Description                                                | Requirements                                                                                          |
| -------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `onboarding`   | Registering a new user in the system.                      | `tenantId`, `tenantSecret` (required).                                                                |
| `auth`         | Verifying the identity of an existing user.                | `tenantId`, `tenantSecret`, **`applicantId`**, **`levelOfTrustToken`** (all required).                |
| `update`       | Updating or re-verifying the identity of an existing user. | `tenantId`, `tenantSecret`, `applicantId` (required).                                                 |
| `signContract` | Signing contract templates by a user.                      | `tenantId`, `tenantSecret`,**`templateId,`** `applicantId`(required). Optional: `contractParameters`. |

## 6. VALUES DESCRIPTION

| Keys.                      | Values                                                                                                                                                        |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tenantId`                 | **Required**. Write your organization tenant id.                                                                                                              |
| `tenantSecret`             | **Required**. Write your organization tenant secret.                                                                                                          |
| `enrollMode`               | **Required**. Mode of the SDK. (See [Enroll Modes](#5-enroll-modes)).                                                                                         |
| `environment`              | **Required**. Select the EnrollEnvironment: EnrollEnvironment.STAGING for staging and EnrollEnvironment.PRODUCTION for production.                            |
| `enrollCallback`           | **Required**. Callback function to receive success and error response.                                                                                        |
| `localizationCode`         | **Required**. Select your language code LocalizationCode.EN for English, and LocalizationCode.AR for Arabic. The default value is English.                    |
| `googleApiKey`             | **Optional**. Google Api Key to view the user current location on the map.                                                                                    |
| `applicantId`              | **Optional**. Write your Application ID (Required for `auth` ,`update` and `signContract` ).                                                                  |
| `levelOfTrustToken`        | **Optional**. Write your Organization's level of trust (Required for `auth`).                                                                                 |
| `skipTutorial`             | **Optional**. Choose to ignore the tutorial or not.                                                                                                           |
| `appColors`                | **Optional**. Collection of the app colors that you could override, like (primary, secondary, background, successColor, warningColor, errorColor, textColor). |
| `correlationId`            | **Optional**. Correlation ID to connect your User ID with our Request ID.                                                                                     |
| `templateId`               | **Optional**. The ID of the contract to be signed (Required for `signContract`).                                                                              |
| `contractParameters`       | **Optional**. Extra contract parameters for `signContract`.                                                                                                   |
| `enrollForcedDocumentType` | **Optional**. Enroll forced document type to force the users to use a national ID only or a passport only, or allow choosing one of them.                     |
| `requestId`                | **Optional**. Write your request ID to allow continuing a previously initiated request (runaway) instead of starting from the beginning.                      |

## 7. SECURITY NOTES

* Never hardcode `tenantSecret`, `levelOfTrustToken`, or API keys inside the mobile application. Use a secure storage mechanism (e.g., Keychain on iOS, Keystore on Android).
* Regularly update the SDK to the latest stable version for security patches.
* Rooted devices are blocked by default for security reasons.

## 8. Electronic Passport Configuration&#x20;

### 8.1. Android

No additional configuration required. The eNROLL-Android SDK automatically includes:

* `android.permission.NFC`
* `android.hardware.nfc` feature&#x20;
* Innovatrics secure environment properties

These are merged automatically into your app's manifest through Gradle's manifest merger.

### 8.2. iOS

* Add the following to your project info.plist file

```
	<key>com.apple.developer.nfc.readersession.felica.systemcodes</key>
	<array>
		<string>A0000002471001</string>
	</array>
	<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
	<array>
		<string>A0000002471001</string>
	</array>
	<key>NFCReaderUsageDescription</key>
	<string>"YOUR-MSG"</string>
```

* Select your **Target** → **Signing & Capabilities** tab Search for and add **Near Field Communication Tag Reading capability**&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lumin-soft.gitbook.io/ekyc/integration-guide/mobile-plugin/flutter-mobile-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
