iOS SDK - OneKYC SDK
public protocol GoPayEnterpriseSdk: AnyObject {
func getKycManager() -> KycManager
}
public protocol KycManager: AnyObject {
func launchKTPScan(
config: EnterpriseKTPScanConfig,
from viewController: UIViewController,
completion: @escaping (EnterpriseDocumentVerificationResult) -> Void
)
func launchSelfieLiveness(
config: EnterpriseSelfieConfig,
from viewController: UIViewController,
completion: @escaping (EnterpriseDocumentVerificationResult) -> Void
)
func launchSelfieVerification(
config: EnterpriseSelfieConfig,
from viewController: UIViewController,
completion: @escaping (EnterpriseDocumentVerificationResult) -> Void
)
func launchKYCVerification(
config: EnterpriseKYCVerificationConfig,
from viewController: UIViewController,
completion: @escaping (EnterpriseDocumentVerificationResult) -> Void
)
}KycManager exposes four independent KYC flows. Each flow is launched with a single call that also accepts a completion closure — there are no separate register/observe steps.
| Flow | Launch function | Config type | Description |
|---|---|---|---|
| KTP Scan | launchKTPScan | EnterpriseKTPScanConfig | Captures and OCR-reads a KTP (Indonesian ID card). |
| Selfie Liveness | launchSelfieLiveness | EnterpriseSelfieConfig | Detects a live selfie to prevent spoofing. |
| Selfie Verification | launchSelfieVerification | EnterpriseSelfieConfig | Matches a selfie against a reference document. |
| KYC Verification | launchKYCVerification | EnterpriseKYCVerificationConfig | Full KYC combining document and selfie checks. |
Configuration Types
EnterpriseKTPScanConfig
public struct EnterpriseKTPScanConfig {
public let baseUrl: String
public let token: String
public let correlationId: String
public let language: String
public let theme: DigitalIdentityKTPScanFlowTheme?
public init(baseUrl: String, token: String, correlationId: String, language: String,
theme: DigitalIdentityKTPScanFlowTheme? = nil)
}EnterpriseSelfieConfig
Used for both Selfie Liveness and Selfie Verification flows.
public struct EnterpriseSelfieConfig {
public let baseUrl: String
public let token: String
public let correlationId: String
public let language: String
public let theme: DigitalIdentitySelfieFlowTheme?
public init(baseUrl: String, token: String, correlationId: String, language: String,
theme: DigitalIdentitySelfieFlowTheme? = nil)
}EnterpriseKYCVerificationConfig
public struct EnterpriseKYCVerificationConfig {
public let baseUrl: String
public let token: String
public let correlationId: String
public let language: String
public let theme: DigitalIdentityKYCVerificationFlowTheme?
public init(baseUrl: String, token: String, correlationId: String, language: String,
theme: DigitalIdentityKYCVerificationFlowTheme? = nil)
}Shared config fields
| Field | Type | Required | Description |
|---|---|---|---|
| baseUrl | String | Yes | Base URL of the KYC backend service. Provided by GoPay as part of your integration credentials. |
| token | String | Yes | Short-lived JWT for authenticating the KYC request. Issued by your backend for the current user session. |
| correlationId | String | Yes | Unique identifier linking the client user to GoPay. Typically the userCorrelationId from the verify exchange flow. |
| language | String | Yes | BCP-47 language tag for the UI. Use "en_ID" for English or "id_ID" for Bahasa Indonesia. |
| theme | DigitalIdentity*FlowTheme? | No | Optional visual theming for the flow UI. Pass nil to use the default GoPay theme. See Theme section below. |
Theme
Each config struct accepts an optional theme parameter for customising the visual appearance of the respective flow. The theme types are provided by the DigitalIdentity framework.
| Config type | Theme type |
|---|---|
EnterpriseKTPScanConfig | DigitalIdentityKTPScanFlowTheme |
EnterpriseSelfieConfig | DigitalIdentitySelfieFlowTheme |
EnterpriseKYCVerificationConfig | DigitalIdentityKYCVerificationFlowTheme |
All theme parameters default to nil, which applies the standard GoPay theme. To apply a custom theme, construct the appropriate DigitalIdentity*FlowTheme object and pass it to the config initialiser:
import DigitalIdentity
let theme = DigitalIdentityKTPScanFlowTheme(/* customise as needed */)
let config = EnterpriseKTPScanConfig(
baseUrl: "https://kyc.example.com",
token: "user-jwt-token",
correlationId: "user-correlation-id",
language: "en_ID",
theme: theme
)Refer to the DigitalIdentity framework documentation for the available theming properties on each theme type.
Result Types
EnterpriseDocumentVerificationResult
Delivered to the completion closure after a flow completes, is cancelled, or errors.
public struct EnterpriseDocumentVerificationResult {
public var correlationId: String
public var status: EnterpriseDocumentVerificationResultStatus
public var submissionId: String?
public var extra: EnterpriseResultExtraData?
}
public enum EnterpriseDocumentVerificationResultStatus: String {
case completed
case notCompleted
case error
}| Field | Description |
|---|---|
| correlationId | The correlation ID provided in the config for this flow. |
| status | .completed on success, .notCompleted if cancelled/dropped, .error if a failure occurred. |
| submissionId | Backend submission reference for this attempt. Present when status == .completed. |
| extra | Present when status == .notCompleted or .error. Carries error code and message details. |
EnterpriseResultExtraData
public struct EnterpriseResultExtraData: Codable {
public var errorCode: EnterpriseFlowErrorCode?
public var errorMessage: String?
}
public enum EnterpriseFlowErrorCode: String, Codable {
case CAMERA
case PERMISSION
case NETWORK
case USER_CANCELLED
case VERIFICATION
}| Error Code | Description |
|---|---|
| CAMERA | Camera could not be opened or is unavailable. |
| PERMISSION | Required camera permission was not granted by the user. |
| NETWORK | A network failure occurred during the flow. |
| VERIFICATION | Verification logic failed (e.g. liveness check not passed). |
| USER_CANCELLED | User navigated back or dismissed the flow without completing. |
Example Usage
// 1. Obtain KycManager from the initialized SDK instance
let kycManager = sdk.getKycManager()
// 2. Build a config
let config = EnterpriseKTPScanConfig(
baseUrl: "https://kyc.example.com",
token: "user-jwt-token",
correlationId: "user-correlation-id",
language: "en_ID"
)
// 3. Launch KTP Scan — result is delivered via completion closure
kycManager.launchKTPScan(config: config, from: self) { result in
switch result.status {
case .completed:
print("KTP scan complete. Submission ID: \(result.submissionId ?? "")")
case .notCompleted:
print("KTP scan not completed: \(result.extra?.errorCode?.rawValue ?? "unknown")")
case .error:
print("KTP scan error: \(result.extra?.errorMessage ?? "unknown")")
}
}
// 4. Selfie liveness
let selfieConfig = EnterpriseSelfieConfig(
baseUrl: "https://kyc.example.com",
token: "user-jwt-token",
correlationId: "user-correlation-id",
language: "en_ID"
)
kycManager.launchSelfieLiveness(config: selfieConfig, from: self) { result in
print("Selfie liveness status: \(result.status.rawValue)")
}
// 5. KYC verification (full flow)
let kycConfig = EnterpriseKYCVerificationConfig(
baseUrl: "https://kyc.example.com",
token: "user-jwt-token",
correlationId: "user-correlation-id",
language: "en_ID"
)
kycManager.launchKYCVerification(config: kycConfig, from: self) { result in
switch result.status {
case .completed:
print("KYC complete. Submission ID: \(result.submissionId ?? "")")
case .notCompleted, .error:
let code = result.extra?.errorCode?.rawValue ?? "none"
let message = result.extra?.errorMessage ?? ""
print("KYC did not complete [\(code)]: \(message)")
}
}Usage Notes
- Call
getKycManager()with no arguments. Obtain it from the initializedGoPayEnterpriseSdkinstance. - The completion closure is called on the main thread.
- Each
launch*function presents a new UI flow on top of the providedviewController. Ensure the view controller is part of an active navigation stack. - All three config fields (
baseUrl,token,correlationId) must be non-empty. Passing blank values may result in a runtime failure from the KYC service. correlationIdis typically theuserCorrelationIdobtained fromExchangeResult.successduring the verify flow.languagemust be a valid BCP-47 locale tag. Use"en_ID"or"id_ID".- The
themeparameter is optional and defaults tonil(standard GoPay theme). Pass a typedDigitalIdentity*FlowThemeinstance to apply custom branding. Import theDigitalIdentityframework in the file where you construct the theme. - The SDK must be initialized (via
GoPayEnterpriseFactory.createEnterpriseSdk) before calling any KYC flow.
Updated about 13 hours ago