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.


FlowLaunch functionConfig typeDescription
KTP ScanlaunchKTPScanEnterpriseKTPScanConfigCaptures and OCR-reads a KTP (Indonesian ID card).
Selfie LivenesslaunchSelfieLivenessEnterpriseSelfieConfigDetects a live selfie to prevent spoofing.
Selfie VerificationlaunchSelfieVerificationEnterpriseSelfieConfigMatches a selfie against a reference document.
KYC VerificationlaunchKYCVerificationEnterpriseKYCVerificationConfigFull 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

FieldTypeRequiredDescription
baseUrlStringYesBase URL of the KYC backend service. Provided by GoPay as part of your integration credentials.
tokenStringYesShort-lived JWT for authenticating the KYC request. Issued by your backend for the current user session.
correlationIdStringYesUnique identifier linking the client user to GoPay. Typically the userCorrelationId from the verify exchange flow.
languageStringYesBCP-47 language tag for the UI. Use "en_ID" for English or "id_ID" for Bahasa Indonesia.
themeDigitalIdentity*FlowTheme?NoOptional 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 typeTheme type
EnterpriseKTPScanConfigDigitalIdentityKTPScanFlowTheme
EnterpriseSelfieConfigDigitalIdentitySelfieFlowTheme
EnterpriseKYCVerificationConfigDigitalIdentityKYCVerificationFlowTheme

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
}
FieldDescription
correlationIdThe correlation ID provided in the config for this flow.
status.completed on success, .notCompleted if cancelled/dropped, .error if a failure occurred.
submissionIdBackend submission reference for this attempt. Present when status == .completed.
extraPresent 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 CodeDescription
CAMERACamera could not be opened or is unavailable.
PERMISSIONRequired camera permission was not granted by the user.
NETWORKA network failure occurred during the flow.
VERIFICATIONVerification logic failed (e.g. liveness check not passed).
USER_CANCELLEDUser 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 initialized GoPayEnterpriseSdk instance.
  • The completion closure is called on the main thread.
  • Each launch* function presents a new UI flow on top of the provided viewController. 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.
  • correlationId is typically the userCorrelationId obtained from ExchangeResult.success during the verify flow.
  • language must be a valid BCP-47 locale tag. Use "en_ID" or "id_ID".
  • The theme parameter is optional and defaults to nil (standard GoPay theme). Pass a typed DigitalIdentity*FlowTheme instance to apply custom branding. Import the DigitalIdentity framework in the file where you construct the theme.
  • The SDK must be initialized (via GoPayEnterpriseFactory.createEnterpriseSdk) before calling any KYC flow.