Structure
PCKYCManager
public struct PCKYCManager
Works with PC KYC-Connector — a server component to perform the remote identification of the client before creating the key.
Properties
Methods
startSession(kycInfoJSON:deviceToken:targetQueue:completion:)
public static func startSession(kycInfoJSON: String, deviceToken: String?, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<PCKYCSession, Error>) -> Void)
Creates and start session to interact with KYC-Connector using configuration from JSON
Includes following steps:
- Key pair generation
- Registration of public key
- Saving received session ID for further interaction
Parameters
Name | Type | Description |
---|---|---|
kycInfoJSON | String |
The KYC-connector configuration in JSON format |
deviceToken | String? |
The device's token for PUSH-notifications |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<PCKYCSession, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns the new |
startSession(kycConnectorURL:systemID:appExtra:deviceToken:targetQueue:completion:)
public static func startSession(kycConnectorURL: URL, systemID: String?, appExtra: [String: Any]?, deviceToken: String?, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<PCKYCSession, Error>) -> Void)
Creates and start session to interact with KYC-Connector
Includes following steps:
- Key pair generation
- Registration of public key
- Saving received session ID for further interaction
Parameters
Name | Type | Description |
---|---|---|
kycConnectorURL | URL |
The url of the KYC-connector |
systemID | String? |
The identifier of the system paired with KYC-connector |
appExtra | [String: Any]? |
An additional information |
deviceToken | String? |
The device's token for PUSH-notifications |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<PCKYCSession, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns the new |
closeSession(session:)
public static func closeSession(session: PCKYCSession)
Closes the session and removes all it data
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be closed |
getSessionStatus(session:targetQueue:completion:)
public static func getSessionStatus(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<PCKYCSessionStatus, Error>) -> Void)
Retrieves the current status of the session
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be retrieved the status for |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<PCKYCSessionStatus, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns |
getRequiredSources(session:targetQueue:completion:)
public static func getRequiredSources(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Set<PCKYCMediaType>, Error>) -> Void)
Gets required sources from server which must be uploaded again to succeed OCR
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be the required sources fetched for |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Set<PCKYCMediaType>, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns the set of |
getStatusHistory(session:targetQueue:completion:)
public static func getStatusHistory(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<[PCKYCSessionStatus], Error>) -> Void)
Gets status history
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be the history fetched for |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<[PCKYCSessionStatus], Error>) -> Void |
A closure to be invoked after getting result |
result | Returns the array of |
uploadMedia(mediaURL:type:session:targetQueue:completion:)
public static func uploadMedia(mediaURL: URL, type: PCKYCMediaType, session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)
Uploads the media of specified type to the server in order to perform an analysis
Parameters
Name | Type | Description |
---|---|---|
mediaURL | URL |
The url of the file to be uploaded |
sourceType | The type of the media |
|
session | PCKYCSession |
The session to be used for uploading media |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns nothing when success. Otherwise, returns error |
uploadMedia(data:extension:type:session:targetQueue:completion:)
public static func uploadMedia(data: Data, extension: String, type: PCKYCMediaType, session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)
Uploads the media of specified type to the server in order to perform an analysis
Parameters
Name | Type | Description |
---|---|---|
data | Data |
The data of the file to be uploaded |
extension | String |
The extension of the media. E.g. 'png'. |
sourceType | The type of the media |
|
session | PCKYCSession |
The session to be used for uploading media |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns nothing when success. Otherwise, returns error |
getOCRResults(session:targetQueue:completion:)
public static func getOCRResults(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<String, Error>) -> Void)
Gets results of OCR procedure. If OCR is done successfully, the results are returned as a raw string. Its content depends on the type of enabled analyser
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be used to get results |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<String, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns OCR results or error |
approveOCRResults(session:targetQueue:completion:)
public static func approveOCRResults(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)
Approves results of OCR. Supposed to be called after OCR is successful and user is shown the way their documents were processed
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be used to approve results |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns OCR results or error |
declineOCRResults(session:targetQueue:completion:)
public static func declineOCRResults(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)
Declined results of OCR. Supposed to be called after OCR is successful and user is shown the way their documents were processed
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be used to decline results |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns OCR results or error |
getPCUser(session:targetQueue:completion:)
public static func getPCUser(session: PCKYCSession, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<PCUser, Error>) -> Void)
Retrieves a PC key from server and returns PCUser
object ready to be used in the app.
This function is supposed to be called only when the session reaches
status PCKYCSessionStatus.analysedSuccessfully
Parameters
Name | Type | Description |
---|---|---|
session | PCKYCSession |
The session to be used to decline results |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<PCUser, Error>) -> Void |
A closure to be invoked after getting result |
result | Returns OCR results or error |