# myid

MyID SDK flutter plugin.

## Table of contents

- [Project adjustments](#project-adjustments)
- [Usage](#usage)
- [SDK error codes](#sdk-error-codes)
- [Theme](#theme)

Android SDK: `1.1.0`

iOS SDK: `2.3.1`

## Project adjustments

### iOS

Update your iOS configuration files

Change `ios/Podfile` to use version 12:

```ruby
platform :ios, '12.0'
```

Add descriptions for camera permission to `ios/YourProjectName/Info.plist`:

```xml
<plist version="1.0">
<dict>
  <!-- Add these two elements: -->
    <key>NSCameraUsageDescription</key>
    <string>Required for document and facial capture</string>
  <!-- ... -->
</dict>
</plist>
```

## Usage

```dart
 var result = await MyIdClient.start(
    config: MyIdConfig(
        clientId: clientId,
        clientHash: clientHash,
        clientHashId: clientHashId,
        passportData: 'AB1234567',
        dateOfBirth: '01.09.1991',
        buildMode: MyIdBuildMode.PRODUCTION
    ),
    iosAppearance: MyIdIOSAppearance(),
);

```

**Parameters details**:

Method | Notes | Default
--- | --- | ---
`clientHash` | Client Hash | Provided by MyID sales team. Mandatory, if using entryType = MyIdEntryType.AUTH
`clientHashId` | Client Hash ID | Provided by MyID sales team. Mandatory, if using entryType = MyIdEntryType.AUTH
`passportData` | Passport serial number or PINFL data | Optional
`dateOfBirth` | Date of birth in. Format: `dd.MM.yyyy` | Optional
`sdkHash` | 32 characters long string (Note 1.2) | Optional
`externalId` | 36 characters long. Should match with UUID4 regex (Note 1.3) | Optional
`threshold` | The value can be in the range of `0.55` - `0.99` | 0.55
`buildMode` | Build mode (Note 1.4) | MyIdBuildMode.PRODUCTION
`entryType` | Customizing the SDK Entry types (Note 1.5) | MyIdEntryType.AUTH
`residency` | To set a specific resident type | MyIdResidentType.RESIDENT
`locale` | To set a specific locale | MyIdLocale.UZBEK
`cameraShape` | To set a specific camera shape | MyIdCameraShape.CIRCLE
`resolution` | To set a specific camera resolution | MyIdResolution.RESOLUTION_480
`imageFormat` | To set a specific image format | MyIdImageFormat.PNG
`organizationDetails` | Custom Organization Details | Optional
`withPhoto` | Return SDK base64 | false

**Note 1.1.** You can customize the screen for entering passport data and date of birth in your
application, in which case you can pass these parameters during initialization to the SDK, otherwise
the SDK requires the input of passport data and date of birth for user identification.

**Note 1.2.** If the `sdk_hash` is empty, blank or string with length other than 32 has been
provided, we will continue showing the credentials screen.

**Note 1.3.** If the `externalId` is not empty, has a length of 36 characters and corresponds to the
regular expression UUID4, we will display a [recommendation](images/screen01.jpg) screen in case the
sdk detects a blurry photo.

**Note 1.4.** `MyIdBuildMode` contains **DEBUG** and **PRODUCTION** modes.

- **DEBUG** is used to sandbox.
- **PRODUCTION** is used to production.

**Note 1.5.** `MyIdEntryType` contains **AUTH** and **FACE** types.

- **AUTH** is used to identify the user through the MyID services.
- **FACE** is used to detect a face and returns a picture (bitmap).

**Note 1.6.** `MyIdCameraShape` contains **[CIRCLE](images/screen03.jpg)**
and **[ELLIPSE](images/screen04.jpg)** types.

## Theme

For [**Android**](https://gitlab.myid.uz/myid-public-code/myid-sample-android/-/blob/master/CUSTOMIZATION.md)

For **iOS** theme config use `MyIdIOSAppearance` class and its properties.

* `primaryColor`: Defines the color of SDK which guides the user through the flow

* `errorColor`: Defines the color of the error buttons, icons and states

* `primaryButtonColor`: Defines the background color of the primary action buttons

* `primaryButtonColorDisabled`: Defines the background color of the primary disabled buttons

* `primaryButtonTextColor`: Defines the color of the text inside the primary action buttons

* `primaryButtonTextColorDisabled`: Defines the color of the text inside the primary disabled buttons

* `buttonCornerRadius`: Defines the radius dimension of all the corners of primary buttons

## Custom Organization Details

You can customize the SDK, for it to match your organization's brand book, by
providing `MyIdOrganizationDetails` object to `organizationDetails` method. The object allows you to
customize following fields:

- *phoneNumber* - by default 712022202, which is MyID's call center. If you would like the customer
  to call your own call center, you can display your own phone number on the error screen, by
  providing it in this field ([sample](images/screen01.jpg)).
- *logo* - the image drawable name, that will be displayed on the input screen. If you would like to
  display your own logo on the top of the screen, this is the place to provide it. Make sure it fits
  the imageView element, which has the *240x60* size.

## SDK error codes

The error code in the following list may appear during the call of SDK. The list below is for your
reference.

| Code |      Error message
|:----:|:-------------
|  2   |  Паспортные данные введены неправильно
|  3   |  Не удалось подтвердить жизненность
|  4   |  Не удалось распознать
|  5   |  Внешний сервис недоступен или работает некорректно
|  6   |  Запрашиваемый пользовател скончался
|  7   |  Фото с ресурсов не получено
|  8   |  Внутренняя ошибка MyID
|  9   |  Срок выполнения задачи истек
|  10  |  Срок ожидания задачи в очереди истек
|  11  |  Сервис MyID не может обработать запрос. Попробуйте повторить позже
|  12  |  Сервис MyID не может обработать запрос. Попробуйте повторить позже
|  13  |  Сервис MyID не может обработать запрос. Попробуйте повторить позже
|  14  |  Не удалось подтвердить жизненность. Некорректная фотография
|  15  |  Сервис MyID не может обработать запрос. Попробуйте повторить позже
|  16  |  Сервис MyID не может обработать запрос. Попробуйте повторить позже
|  17  |  Не удалось распознать. Некорректная фотография
|  18  |  Сервис проверки жизненности не может обработать запрос
|  19  |  Сервис распознования не может обработать запрос
|  20  |  Размытая фотография
|  21  |  Лицо не полностью изображено
|  22  |  Обнаружено несколько лиц
|  23  |  Представленное изображение в градациях серого, требуется цветное изображение
|  24  |  Обнаружены затемненные очки
|  25  |  Тип фотографии не поддерживается
|  26  |  Глаза закрыты либо не видны
|  27  |  Обнаружено вращение головы
|  28  |  Не удалось обнаружить все ориентиры
| 101  |  Непредвиденная ошибка
| 102  |  Доступ к камере запрещен
| 103  |  Ошибка при получении данных с сервера
| 120  |  Размытое фото обнаружено в SDK

## Getting Started with Flutter plugins

This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
