Nhảy tới nội dung

iOS SDK

Table of Contents

About The Project

This project is developed by FCI Team. This is a project to build a framework that provides the function of electronic know your customer (eKYC) on four kinds of Vietnam identity documents as identity card (with and without chip), driving lisence and passport.

Getting Started

Prerequisites

  • Xcode 13.3 and above
  • Cocoapod v1.11.3
  • A physical iOS device
  • An Apple developer account

Integrate framework

  • Please contact FCI to obtain the SDK and other necessary information.

  • Install

To integrate the eKYC into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'eKYC', :path => "eKYC/"

Replace the temporary path with the path that you place unzipped eKYC framework.

Relative paths can be used. In case you put the framework in the same directory as the Podfile, the above declaration is correct.

  1. Install the pod into your project by typing in terminal:
pod install
  • Add capability to your Xcode target: Near Field Communication Tag Reading IDCardReader requires following keys in Info.plist:
<key>NFCReaderUsageDescription</key>
<string>NFC tag to read NDEF messages into the application</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
</array>

// add request camera
<key>NSCameraUsageDescription</key>
<string>Please allow the app uses camera for detecting information from identity documents</string>


// add your font use in your project and set name font from portal
<key>UIAppFonts</key>
<array>
<string>AvertaStdCY-Bold.otf</string>
<string>AvertaStdCY-Semibold.otf</string>
<string>AvertaStdCY-Regular.otf</string>
</array>

  • Usage

full eKYC:

var config = FEKYCConfig()
config?.setApiKey("")
config?.setUUID("")
config?.setDocType(.idCard) // type of paper (.idcard, .passport)
config?.setEnvironment(.staging) // enviroment
config?.setLang("vi") // language in sdk
config?.setCountry("vn") // nation
config?.setTheme(.light) // .light, .dark
config?.setScreeShield(true) // not allow cap screen
config?.setShowLog(true) // show log ressponse api

FEKYC.startFPTEKYCFlow(withConfig: config, from: v) { result in
// result is string json compared to previous version which was json
if let data = result.data(using: .utf8),
let dict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
print("👉 Dictionary:", dict)
}
} onFail: { resultFail, errorString in
// resultFail is string json compared to previous version which was json
if let data = resultFail.data(using: .utf8),
let dict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
print("👉 Dictionary:", dict)
}
} onTracking: { tracking in
print(tracking)
}

only NFC:

var documentData :[[String:Any]] = []
var idNum : [String:Any] = [:]
idNum["key"] = "ID"
idNum["value"] = ""

var dob : [String:Any] = [:]
dob["key"] = "Date of birth"
dob["value"] = ""

var doe : [String:Any] = [:]
doe["key"] = "Expired Date"
doe["value"] = ""
documentData.append(idNum)
documentData.append(dob)
documentData.append(doe)

var config = FEKYCConfig()
config?.setApiKey("")
config?.setUUID("")
config?.setDocType(.nfc)
config?.setEnvironment(.staging)
config?.setLang("vi")
config?.setCountry("vn")
config?.setDocumentData(documentData) // set info of user

FEKYC.startFPTEKYCFlow(withConfig: config, from: v) { result in
print(result)
} onFail: { resultFail, errorString in
print(resultFail)
} onTracking: { tracking in
print(tracking)
}

only OCR:

var config = FEKYCConfig()
config?.setApiKey("")
config?.setUUID("")
config?.setEnvironment(.staging)
config?.setLang("vi")
config?.setCountry("vn")
config?.setDocOnly(true) // just ocr

FEKYC.startFPTEKYCFlow(withConfig: config, from: v) { result in
print(result)
} onFail: { resultFail, errorString in
print(resultFail)
} onTracking: { tracking in
print(tracking)
}

only Liveness:

var config = FEKYCConfig()
config?.setApiKey("")
config?.setSessionId("abc") // truyền thêm sessionID để check facematch với phiên đó
config?.setUUID("")
config?.setEnvironment(.staging)
config?.setLang("vi")
config?.setCountry("vn")
config?.setFlow("6") // flow sdk (6: just liveness)
config?.setLiveType(1) // livenessType (0,1)

FEKYC.startFPTEKYCFlow(withConfig: config, from: v) { result in
print(result)
} onFail: { resultFail, errorString in
print(resultFail)
} onTracking: { tracking in
print(tracking)
}

In which:

  • apiKey: is the key provided by FCI to a third party. The process of processing images and comparing information in documents and selfies will be done on FCI's server and provided in the form of public APIs. Only when owning a valid api key can the sdk be able to connect to the backend. Please contact FPT Smart Cloud for provision.
  • sessionId:
  • orcTypes: An array of document types that third parties want to provide to end users. Where .idCard is the citizen identification, excluding the function of reading information from chip card, .nfc is the citizen identification with the function of reading information from chip card, .driveLicense is for driving license, and finally .passport is for users who want to do eKYC with passport.
  • environment: .
  • The result, which will be returned in the closure, is the string json object contains personal information.
  • customInfo: is the info you download from portal, then copy to your project and config like example.

Note: Because our SDk only support portrait. if your app support landscape then add following code:

Add this to Appdelegate:

var orientationLock = UIInterfaceOrientationMask.all
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return self.orientationLock
}

Add this from any swift class:

struct AppUtility {
static func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
if let delegate = UIApplication.shared.delegate as? AppDelegate {
delegate.orientationLock = orientation
}
}
}

When start SDK you add this: AppUtility.lockOrientation(.portrait) and this: AppUtility.lockOrientation(.all) when receive result from sdk

For example:

AppUtility.lockOrientation(.portrait)
FEKYC.startFPTEKYCFlow(withConfig: config5, from: self) { result in
AppUtility.lockOrientation(.all)
print(result)
}

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

FPT.AI - support@fpt.ai

FPT Tower, 10 Pham Van Bach street, Cau Giay District, Hanoi, Vietnam

1900 638 399

Project Link: https://github.com/

Acknowledgments

During development, we consulted from the following sources: