• Home
  • Features
  • Spec
  • Guides
  • Sandbox
  • Overview
  • Quick start
    • Integrating on Web
    • Integrating on iOS
    • Integrating on Android
  • Writing or editing a flow
  • Working with custom renderers
  • Analytics

Integrating on iOS

This page is for Wise engineers who want to integrate an existing flow into their product in the Wise iOS app.

To use Dynamic Flow, you need to import two frameworks:

import DynamicFlow
import DynamicFlowKit

TWDynamicFlowFactory contains the methods needed to create a Flow<Result<T, FlowFailure>> where T is the type of result you expect from the flow. As long as your type T is Decodable, no further configuration is needed. It is possible to use non-decodable types but these are currently out of scope for this guide. As an example, a flow that returns an instance of Recipient would have the type Flow<Result<Recipient, FlowFailure>>. Notice that the flow can also end in an error of type FlowFailure. This will only be used in the case of an unrecoverable error within the DF flow.

The simplest approach to creating a flow is using an ApiKit Resource with a response type of DynamicFlowHttpResponse. For example, you could use the following:

let parameters = .makeQueryUrlParameter("recipientId", value: "true", sensitive: false)

let resource = RestGwResource<DynamicFlowHTTPResponse>(
    path: "/v1/recipient-requirements/{recipientId}",
    method: .get,
    parameters: parameters,
    parser: DynamicFlowHTTPResponse.parser
)

Please note that you must provide the DynamicFlowHttpResponse.parser as the parser for the Resource. This is because Dynamic Flow makes use of response headers which will otherwise be unavailable.

The flow is now ready to be built using the makeFlow method, as in the following example:

let flow: any Flow<Result<Recipient, FlowFailure>> = TWDynamicFlowFactory().makeFlow(
    resource: resource,
    presentationStyle: .push(navigationController: hostViewController),
    analyticsFlowTracker: analyticsFlowTracker
)
flow.flowHandler = FlowHandler(finished: { [weak self] result, _ in
    // Handle termination
})
flow.start()