Launch Feature

Launch Feature Request

The launch feature flow is initiated by calling FeatureManager.launchFeature() with a FeatureRequest built via the Builder API. Unlike verify(), launchFeature() requires featureId to identify which feature to launch, in addition to requestId and userCorrelationId.

let request = FeatureRequest.Builder()
    .requestId(UUID().uuidString)
    .featureId("some-feature-id")
    .userCorrelationId("corr-5678")
    .token("host-app-token")
    .build()

Field nameDescription
requestIdUnique identifier for the request, generated by the client. Required — callback.onError(GPE-2206) is called if blank.
featureIdIdentifier of the feature to launch. Required — callback.onError(GPE-2206) is called if blank.
userCorrelationIdIdentifier linking the client user to GoPay. Required — callback.onError(GPE-2206) is called if blank.
tokenThe linking token for the user. Required — callback.onError(GPE-2206) is called if blank.

Note: FeatureRequest.Builder.build() does not validate fields. Validation happens inside launchFeature()featureId, userCorrelationId, requestId, and token are all checked; if any is blank, callback.onError is called with GPE-2206, not a thrown error.

LaunchResult

callback.onComplete is called with a LaunchResult upon successful completion.

public struct LaunchResult {
    public let featureId: String
}

FieldDescription
featureIdEchoes back the identifier of the feature that was launched.

Note: If launchFeature() is called before the SDK's internal router has finished initializing, callback.onError is currently called with a non-standard "NO_ROUTER" error code — not one of the documented GPE- codes (see Error Codes). Treat this as a signal that GoPayEnterpriseFactory.createEnterpriseSdk has not finished initializing; avoid calling launchFeature() until initialization completes.

Example Usage

let request = FeatureRequest.Builder()
    .requestId(UUID().uuidString)
    .featureId("some-feature-id")
    .userCorrelationId("corr-5678")
    .token("host-app-token")
    .build()

final class LaunchFeatureCallback: FeatureCallback {
    typealias Result = LaunchResult

    func onComplete(result: LaunchResult, data: [String: Any]) {
        print("Launched featureId: \(result.featureId)")
    }

    func onError(error: GoPayEnterpriseError) {
        print("Error [\(error.code)]: \(error.title) — \(error.message)")
    }
}

let callback = LaunchFeatureCallback()
self.launchCallback = callback  // retain strongly

do {
    try sdk.getFeatureManager().launchFeature(
        viewController: self,
        request: request,
        callback: AnyFeatureCallback(wrapping: callback)
    )
} catch {
    print("launchFeature threw: \(error)")
}

Usage Notes

  • Always call launchFeature() on the main thread.
  • launchFeature() is marked throws — wrap it in a do-catch block.
  • build() does not throw — validation is performed inside launchFeature(). Ensure featureId, userCorrelationId, requestId, and token are all non-blank before calling.
  • Generate a fresh requestId for every launchFeature() call, the same as for verify().
  • launchFeature() has no credentialReceiver parameter — no auth-code exchange is performed.
  • featureId must be whitelisted for your clientID; otherwise callback.onError is called with GPE-2204.
  • Keep a strong reference to your FeatureCallback instance for the duration of the flow. AnyFeatureCallback holds it weakly.
  • The launched feature is presented full-screen; onComplete is called once the flow is dismissed.

Did this page help you?