# Hướng dẫn tích hợp

SDK xác thực

### Tính năng

- Xác thực khuôn mặt
- Xác thực OTP

# Cài đặt

### Flutter

Thực hiện câu lệnh sau:

```bash
~ flutter pub add mfa
```

Câu lệnh này sẽ thêm vào `pubspec.yaml` dòng sau

```yaml
dependencies:
  mfa: ^1.0.0
```

### import

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

final _mfa = Mfa();
_mfa.faceCheck(
  debug, //require TRUE or FALSE
  token,     //Require
  (result) {
    print("Result: $result");
  }, //callback
);

_mfa.genToken(
phone,
cif,
clientId,
transId, //TransID
(result) {
print("ResponseKyc: $result");
}, //callback
);

```

**Mô tả các trường dữ liệu.**

| debug | bool |
| --- | --- |
| appCode | string |
| key | string |
| transID | string |

Thư viện này được cung cấp giới hạn cho đối tác nhất định và cần cấu hình đặc thù riêng cho `Android` và `IOS`, bạn cần làm theo các bước sau.

### Android

**Yêu cầu**

- `minSDK` 24
- Permission `Camera`, `Storage`, `Audio`, `Biometric`, `Internet`

Cấu hình `manifest`:

```xml
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-feature android:name="android.hardware.camera"/>
```

Cấu hình `maven`:

```groovy
allprojects {
    repositories {
        maven { url "https://maven.google.com" }
        maven { url "https://jitpack.io" }
        maven {
            url = uri("https://maven.pkg.github.com/pvcbdigibank/SDK_MFA_ANDROID")
            credentials {
                username = ""
                password = "<Access Key>"
            }
        }
    }
}
```

`<Access Key>` được cung cấp riêng.

### IOS

**Request**

- Minimum iOS Deployment Target: 12.0
- Xcode 15.3 or newer
- Swift 5.10 or newer
- Permissions: Camera, NFC

**iOS setup**

1. Add information to the `Info.plist` file

You need add permissions: `Camera`, `NFC`, `ISO 7816`

```swift
<key>NSCameraUsageDescription</key>
<string>Camera permission</string>
<key>NFCReaderUsageDescription</key>
<string>NFC permission</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
  <string>00000000000000</string>
  <string>A0000002471001</string>
  <string>A0000002472001</string>
</array>

```

### 2. You need add Capability: `Near Field Communication Tag Reading`

If your project use `Minimum Deployments < iOS 13.0`, you need add `NDEF` in `Near Field Communication Tag Reader Session Formats`

### Important note

If you compile the project and get the following errors:

- Pods `Alamofire`, `CryptoSwift`, `SnapKit`, `lottie-ios`, `KeychainSwift`, `ObjectMapper` were not found
- Related to `IPHONEOS_DEPLOYMENT_TARGET`
- Swift version conflict

Please add the following content to your project's `Podfile` in `post_install do |installer|`

```swift
installer.pods_project.targets.each do |target|
  if ["Alamofire", "CryptoSwift", "SnapKit", "lottie-ios", "KeychainSwift", "ObjectMapper"].include? "#{target}"
    target.build_configurations.each do |config|
      config.build_settings["BUILD_LIBRARY_FOR_DISTRIBUTION"] = "YES"
      # Xcode 14 supports only iOS >= 11.0.
      deployment_target = config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"]
      if !deployment_target.nil? || !deployment_target.empty? || deployment_target.to_f < 12.0
        config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = "12.0"
      end
    end
  end
end

```
