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 name | Description |
|---|---|
| requestId | Unique identifier for the request, generated by the client. Required — callback.onError(GPE-2206) is called if blank. |
| featureId | Identifier of the feature to launch. Required — callback.onError(GPE-2206) is called if blank. |
| userCorrelationId | Identifier linking the client user to GoPay. Required — callback.onError(GPE-2206) is called if blank. |
| token | The linking token for the user. Required — callback.onError(GPE-2206) is called if blank. |
Note:
FeatureRequest.Builder.build()does not validate fields. Validation happens insidelaunchFeature()—featureId,userCorrelationId,requestId, andtokenare all checked; if any is blank,callback.onErroris called withGPE-2206, not a thrown error.
LaunchResult
callback.onComplete is called with a LaunchResult upon successful completion.
public struct LaunchResult {
public let featureId: String
}| Field | Description |
|---|---|
| featureId | Echoes back the identifier of the feature that was launched. |
Note: If
launchFeature()is called before the SDK's internal router has finished initializing,callback.onErroris currently called with a non-standard"NO_ROUTER"error code — not one of the documentedGPE-codes (see Error Codes). Treat this as a signal thatGoPayEnterpriseFactory.createEnterpriseSdkhas not finished initializing; avoid callinglaunchFeature()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 markedthrows— wrap it in ado-catchblock.build()does not throw — validation is performed insidelaunchFeature(). EnsurefeatureId,userCorrelationId,requestId, andtokenare all non-blank before calling.- Generate a fresh
requestIdfor everylaunchFeature()call, the same as forverify(). launchFeature()has nocredentialReceiverparameter — no auth-code exchange is performed.featureIdmust be whitelisted for yourclientID; otherwisecallback.onErroris called withGPE-2204.- Keep a strong reference to your
FeatureCallbackinstance for the duration of the flow.AnyFeatureCallbackholds it weakly. - The launched feature is presented full-screen;
onCompleteis called once the flow is dismissed.
Updated 20 days ago