# eNROLL iOS Framework

## 1. Requirements

* **Xcode**: ≥ 14.2
* **iOS Deployment Target**: ≥ 13.0

***

## 2. Installation

### 🔹 CocoaPods (Recommended)

We now distribute **EnrollFramework** via a **private CocoaPod** for easier integration.

1. Add our private specs repo to your Podfile (before the CocoaPods default one):

   ```ruby
   source 'https://github.com/LuminSoft/eNROLL-iOS-specs.git'
   source 'https://github.com/innovatrics/innovatrics-podspecs'
   source 'https://github.com/CocoaPods/Specs.git'
   ```
2. Add the EnrollFramework pod:

   ```ruby
   pod 'EnrollFramework', '~> 1.5.0'
   ```

   > ✅ You no longer need to declare these pods manually `dot-face-detection-fast`, `dot-face-expression-neutral`, etc.\
   > They are already included in our podspec.
3. Install pods:

   ```sh
   pod repo add eNROLL-iOS-specs https://github.com/LuminSoft/eNROLL-iOS-specs.git
   pod install --repo-update
   ```

***

### 🔹 Manual Installation (Fallback)

If CocoaPods cannot be used, you can still integrate the `.xcframework` manually:

1. Download the latest release from [eNROLL-iOS Releases](https://github.com/LuminSoft/eNROLL-iOS/tags)\
   and extract the `EnrollFramework.xcframework` file.
2. Add it to your project (drag & drop into **Frameworks** section with *Embed & Sign*).

<figure><img src="https://3826285197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGM6tCcdsukNbOigN9U2m%2Fuploads%2FSh4m9cLDxyzQWRD4zjWH%2Fimage.png?alt=media&#x26;token=7f6360d5-a698-44aa-9cfa-8049d9801d69" alt=""><figcaption></figcaption></figure>

3\. Add dependencies to your Podfile:

```ruby
pod 'FirebaseRemoteConfig','11.15.0'
pod 'dot-face-detection-fast', '8.10.0'
pod 'dot-face-background-uniformity', '8.10.0'
pod 'dot-face-expression-neutral', '8.10.0'
pod 'dot-document', '8.10.0'
```

4. Run:

   <pre class="language-sh"><code class="lang-sh"><strong>pod install
   </strong></code></pre>

***

## 3. Configurations

1. Update your **Info.plist**:

   ```xml
   <key>NSCameraUsageDescription</key>
   <string>Your message to users</string>
   <key>NSLocationWhenInUseUsageDescription</key>
   <string>Your message to users</string>
   ```
2. **If you are using Xcode 15 or later**\
   Go to **Build Settings** → search for `User Script Sandboxing` and set it to **NO**.

<figure><img src="https://3826285197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGM6tCcdsukNbOigN9U2m%2Fuploads%2F8BWZZsLCrFVxhRNUOCmk%2Fimage.png?alt=media&#x26;token=31278b62-42f3-41f0-9380-6709bdd34714" alt="" width="551"><figcaption></figcaption></figure>

3. Place your **license file** inside your project (drag & drop into Navigator, with *Copy items if needed* checked).

<figure><img src="https://3826285197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGM6tCcdsukNbOigN9U2m%2Fuploads%2FD22HiplTaCuMTRwHgt8A%2Fimage.png?alt=media&#x26;token=595b27a1-5818-4365-bb23-08b69cb5f015" alt="" width="368"><figcaption></figcaption></figure>

***

## 4. Import

```swift
import EnrollFramework
```

***

## 5. Usage

### 1. Conform to `EnrollCallBack`

```swift
class YourViewController: UIViewController, EnrollCallBack {
    func onInitializeRequest(requestId: String) { }
    func onSuccess(documentNumber: String, applicantId: String) { }
    func onError(message: String) { }
}
```

### 2. Initialize & Present

```swift
do {
    let enrollInitModel = try EnrollInitModel(
        tenantId: "<YOUR_TENANT_ID>",
        tenantSecret: "<YOUR_TENANT_SECRET>",
        enrollEnviroment: .production, // or .staging
        localizationLanguage: .en,         // or .ar
        enrollCallback: self,
        enrollMode: .onboarding        // or .authentication, .update, .forget, .signContarct
    )

    let enrollVC = Enroll.initViewController(
        enrollInitModel: enrollInitModel,
        presenterVC: self
    )

    self.present(enrollVC, animated: true)

} catch {
    print("Error initializing EnrollInitModel: \(error)")
}
```

***

## 6. Values Description

### <mark style="color:orange;">EnrollInitModel Parameters:</mark>

| 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](#7-enroll-modes)).                                                                                                                                                                                                                                                                         |
| `enrollEnviroment`         | **Required**. Select the EnrollEnvironment: `EnrollEnvironment.STAGING` for staging and `EnrollEnvironment.PRODUCTION` for production.                                                                                                                                                                                                        |
| `enrollCallback`           | **Required**. Callback function to receive success and error response.                                                                                                                                                                                                                                                                        |
| `localizationLanguage`     | <p><strong>Required</strong>. Select your language code: <code>LocalizationEnum.EN</code> for English, and <code>LocalizationEnum.AR</code> for Arabic.<br>Default value is <strong>English</strong>.</p>                                                                                                                                     |
| `googleApiKey`             | **Optional**. Google API Key to view the user’s current location on the map.                                                                                                                                                                                                                                                                  |
| `applicantId`              | **Optional**. Write your Application ID (Required for `auth`, `update`, and `signContract`).                                                                                                                                                                                                                                                  |
| `levelOffTrustId`          | **Optional**. Write your Organization's level of trust (Required for `auth`).                                                                                                                                                                                                                                                                 |
| `skipTutorial`             | **Optional**. Choose to ignore the tutorial or not.                                                                                                                                                                                                                                                                                           |
| `enrollColors`             | **Optional**. Collection of app colors you can override: `primary`, `secondary`, `background`, `successColor`, `warningColor`, `errorColor`, `textColor`.                                                                                                                                                                                     |
| `customFontName`           | **Optional**. Font resource to set your font family.                                                                                                                                                                                                                                                                                          |
| `correlationId`            | **Optional**. Correlation ID to connect your User ID with our Request ID.                                                                                                                                                                                                                                                                     |
| `contractTemplateId`       | **Optional**. The ID of the contract to be signed (Required for `signContract`).                                                                                                                                                                                                                                                              |
| `signContarctParam`        | **Optional**. Extra contract parameters for `signContract`.                                                                                                                                                                                                                                                                                   |
| `enrollForcedDocumentType` | <p><strong>Optional</strong>. Accepts values from the <code>EnrollForcedDocumentType</code> enum:<br>- <code>passport</code> → The user must enroll using a passport.<br>- <code>nationalId</code> → The user must enroll using a national ID.<br>- <code>default</code> → Keeps the normal flow with standard document selection screen.</p> |
| `requestId`                | **Optional**. Write your request ID to continue a previously initiated request (runaway) instead of starting from the beginning.                                                                                                                                                                                                              |

### <mark style="color:orange;">EnrollColors:</mark>

Define custom colors for UI components inside the framework.

| Keys               | Values                                                |
| ------------------ | ----------------------------------------------------- |
| primary            | The Primary color used for all buttons and main items |
| secondary          | Used for the minor views and items                    |
| appBackgroundColor | Used for the main background                          |
| textColor          | Used for the text and content color                   |
| errorColor         | Used for the error color                              |
| successColor       | Used for the successful color                         |
| warningColor       | Used for the warning color                            |
| appWhite           | The main white color                                  |
| appBlack           | The main black color                                  |

***

## 7. ENROLL MODES

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

```swift
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`**, **`levelOffTrustId`** (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`,**`contractTemplateId,`** `applicantId`(required). Optional: `signContarctParam`. |
