Skip to main content

Using the iOS Renderer

iOS Project Requirements

The minimum requirements are:
  • iOS 15
  • Swift 5.7

Installing the library

The iOS Renderer is available through Cocoapods.

Cocoapods

Prerequisites

  • Cocoapods gem installed

Cocoapods private trunk setup

Add the private trunk repo to your local Cocoapods installation with the command:

Adding the dependency

Add the source of the private repository in the Podfile
Add a post install hook in the Podfile setting BUILD_LIBRARY_FOR_DISTRIBUTION to YES.
Add the pod and then run pod install
Example

Library dependencies

  • Alamofire
  • SDWebImageSwiftUI
  • SDWebImageSVGCoder

Info.plist permissions

Depending on which SDK features your processes and UI flows use, the host app must declare the corresponding usage descriptions in its Info.plist. Missing keys cause a crash the moment the feature is used. Notes:
  • Document/file pickers (bulk file upload, chat file attachments) use the system files picker and require no permission keys.
  • Sample declarations:

Configuring the library

The SDK has 2 configurations, available through shared instances: FXConfig which holds general purpose properties, and FXSessionConfig which holds user session properties. It is recommended to call the FXConfig configuration method at app launch. Call the FXSessionConfig configure method after the user logs in and a valid user session is available.

FXConfig

This config is used for general purpose properties.

Properties

organizationId is the FlowX-issued organization UUID. On self-hosted deployments it matches the ORGANIZATION_ID configured during the backend upgrade — see License and organization configuration.
Sample

Changing the current language

The current language and locale can be changed after the initial configuration, by calling the changeLocaleSettings method:
For locale, use the format BCP 47. BCP 47 is the standard for representing language and region codes, here is a link to the BCP 47 specification. An example of BCP 47 is en-us (language code - en and region code - us).

FXSessionConfig

This config is used for providing networking or auth session-specific properties. The library expects either the JWT access token or an Alamofire Session instance managed by the container app. In case a session object is provided, the request adapting should be handled by the container app.

Properties

Sample for access token

Sample for session

Theming

Make sure the FXSessionConfig configure method was called with a valid session before setting up the theme.
Before starting or resuming a process, the theme setup API should be called. The start or continue process APIs should be called only after the theme setup was completed.

Theme setup

The setup theme is called using the shared instance of FXTheme
  • uuid - the UUID of the theme configured in the FlowX Designer.
  • workspaceId - the UUID of the workspace the theme belongs to.
  • localFileUrl - optional parameter for providing a fallback theme file, in case the fetch theme request fails.
  • appearance - optional SwiftUI ColorScheme (.light or .dark) used to render the theme. Defaults to .light.
  • completion - a completion closure called when the theme setup finishes.
In addition to the completion parameter, FXTheme’s shared instance also provides a Combine publisher named themeFetched which sends true if the theme setup was finished.

Sample

Using the library

Public API

The library’s public APIs described in this section are called using the shared instance of FlowX, FlowX.sharedInstance.

How to start and end FlowX session

After all the configurations are set, you can start a FlowX session by calling the startSession() method. This is optional, as the session starts lazily when the first process is started. FlowX.sharedInstance.startSession() When you want to end a FlowX session, you can call the endSession() method. This also does a complete clean-up of the started processes. You might want to use this method in a variety of scenarios, for instance when the user logs out. FlowX.sharedInstance.endSession()

How to start a process

There are 3 methods available for starting a FlowX process. The container app is responsible with presenting the navigation controller or tab controller holding the process navigation.
  1. Start a process which renders inside an instance of UINavigationController or UITabBarController, depending on the BPMN diagram of the process.
The controller to be presented is provided through the completion closure parameter of the method.
Use this method when you want the process to be rendered inside a controller themed using the FlowX Theme defined in the FlowX Designer, regardless of the navigation type configured for the process.
  • workspaceId - the uuid of the workspace
  • projectId - the uuid of the project
  • name - the name of the process
  • params - the start parameters, if any
  • isModal - a boolean indicating whether the process navigation is modally displayed. When the process navigation is displayed modally, a close bar button item is displayed on each screen displayed throughout the process navigation.
  • showLoader - a boolean indicating whether the loader should be displayed when starting the process.
  • completion - a completion closure which passes either an instance of UINavigationController or UITabBarController to be presented, alongside the started process instance UUID. The UUID is an empty string if the process failed to start.
  • onProcessEnded - a closure called when the process ends. The closure is strongly referenced inside the SDK. Avoid reference cycles by using [weak self]
  1. Start a process which renders inside a provided instance of a UINavigationController.
Use this method when you want the process to be rendered inside a custom instance of UINavigationController.
Optionally you can pass an instance of FXNavigationViewController, which has the appearance set in the FlowX Theme, using the FXNavigationViewControllers class func FXNavigationViewController.navigationController().
If you use this method, make sure that the process does not use a tab controller as root view.
  • navigationController - the instance of UINavigationController which will hold the process navigation stack
  • workspaceId - the uuid of the workspace
  • projectId - the uuid of the project
  • name - the name of the process
  • params - the start parameters, if any
  • isModal - a boolean indicating whether the process navigation is modally displayed. When the process navigation is displayed modally, a close bar button item is displayed on each screen displayed throughout the process navigation.
  • showLoader - a boolean indicating whether the loader should be displayed when starting the process.
  • onProcessStarted - an optional closure called after the process has been started, providing the process instance UUID.
  • onProcessEnded - a closure called when the process ends. The closure is strongly referenced inside the SDK. Avoid reference cycles by using [weak self]
  1. Start a process which renders inside a provided instance of a UITabBarController.
Use this method when you want the process to be rendered inside a custom instance of UITabBarController.
If you use this method, make sure that the process has a tab controller as root view.
  • tabBarController - the instance of UITabBarController which will hold the process navigation
  • workspaceId - the uuid of the workspace
  • projectId - the uuid of the project
  • name - the name of the process
  • params - the start parameters, if any
  • isModal - a boolean indicating whether the process navigation is modally displayed. When the process navigation is displayed modally, a close bar button item is displayed on each screen displayed throughout the process navigation.
  • showLoader - a boolean indicating whether the loader should be displayed when starting the process.
  • onProcessStarted - an optional closure called after the process has been started, providing the process instance UUID.
  • onProcessEnded - a closure called when the process ends. The closure is strongly referenced inside the SDK. Avoid reference cycles by using [weak self]

Sample

or
or

How to start a UI Flow

UI Flows are lightweight, screen-driven flows defined in the FlowX Designer. They run client-side on top of a data model, without requiring a BPMN process instance on the engine. The container app is responsible with presenting the controller passed in the completion closure.
  • workspaceId - the uuid of the workspace
  • projectId - the uuid of the project
  • name - the name of the UI Flow
  • params - the start parameters, if any
  • isModal - a boolean indicating whether the UI Flow navigation is modally displayed. When the navigation is displayed modally, a close bar button item is displayed on each screen.
  • showLoader - a boolean indicating whether the loader should be displayed when starting the UI Flow.
  • completion - a completion closure which passes either an instance of UINavigationController or UITabBarController to be presented, depending on the navigation configured for the UI Flow.

Sample

How to use the standalone chat

The chat component can be used on its own, outside of any process or UI Flow. The SDK exposes a self-contained SwiftUI view connected to an AI conversational workflow. Prerequisites:
  • FXConfig configured with the environment’s baseURL (and imageBaseURL if themed icons are used)
  • authorization configured through FXSessionConfig / FlowX.sharedInstance.updateAuthorization(token:), or anonymous mode
  • optionally, a theme loaded through FXTheme.setupTheme. Without one, the chat renders with system fallbacks
  • NSMicrophoneUsageDescription in the host app’s Info.plist when voice input is enabled
  • configuration - the connection and UI configuration of the chat
  • onClose - an optional closure, called when the user taps the close button in the chat header. When omitted, the close button is not displayed.
FXChatConfiguration properties:
  • workspaceId - the uuid of the workspace
  • projectId - the uuid of the project the conversational workflow belongs to
  • workflowResDefId - the resource definition uuid of the AI conversational workflow
  • buildId - optional, the uuid of the active build, sent as part of the message context
  • uiFlowSessionUuid / uiFlowResDefId - optional, link the chat to a UI Flow session when embedded alongside one
  • ui - an FXChatUIConfig value controlling content and behaviour: header title and subtitle, welcome and thinking messages, input placeholder, suggested prompts, voice input and file attachments toggles, attachment limits, history title, etc. All fields have defaults.
The chat session lives as long as the returned view’s identity. Recreating the view starts a fresh session.

Sample

Presenting from UIKit:

How to resume an existing process

There are 3 methods available for resuming a FlowX process. The container app is responsible with presenting the navigation controller or tab controller holding the process navigation.
  1. Continue a process which renders inside an instance of UINavigationController or UITabBarController, depending on the BPMN diagram of the process.
The controller to be presented will be provided inside the completion closure parameter of the method.
Use this method when you want the process to be rendered inside a controller themed using the FlowX Theme defined in the FlowX Designer.
  • uuid - the UUID string of the process
  • name - the name of the process
  • isModal - a boolean indicating whether the process navigation is modally displayed. When the process navigation is displayed modally, a close bar button item is displayed on each screen displayed throughout the process navigation.
  • showLoader - a boolean indicating whether the loader should be displayed when resuming the process.
  • completion - a completion closure which passes either an instance of UINavigationController or UITabBarController to be presented.
  • onProcessEnded - a closure called when the process ends. The closure is strongly referenced inside the SDK. Avoid reference cycles by using [weak self]
  1. Continue a process which renders inside a provided instance of a UINavigationController.
Use this method when you want the process to be rendered inside a custom instance of UINavigationController.
Optionally you can pass an instance of FXNavigationViewController, which has the appearance set in the FlowX Theme, using the FXNavigationViewControllers class func FXNavigationViewController.navigationController().
If you use this method, make sure that the process does not use a tab controller as root view.
  • uuid - the UUID string of the process
  • name - the name of the process
  • navigationController - the instance of UINavigationController which will hold the process navigation stack
  • isModal - a boolean indicating whether the process navigation is modally displayed. When the process navigation is displayed modally, a close bar button item is displayed on each screen displayed throughout the process navigation.
  • showLoader - a boolean indicating whether the loader should be displayed when resuming the process.
  • onProcessEnded - a closure called when the process ends. The closure is strongly referenced inside the SDK. Avoid reference cycles by using [weak self]
  1. Continue a process which renders inside a provided instance of a UITabBarController.
Use this method when you want the process to be rendered inside a custom instance of UITabBarController.
If you use this method, make sure that the process has a tab controller as root view.
  • uuid - the UUID string of the process
  • name - the name of the process
  • tabBarController - the instance of UITabBarController which will hold the process navigation
  • isModal - a boolean indicating whether the process navigation is modally displayed. When the process navigation is displayed modally, a close bar button item is displayed on each screen displayed throughout the process navigation.
  • showLoader - a boolean indicating whether the loader should be displayed when resuming the process.
  • onProcessEnded - a closure called when the process ends. The closure is strongly referenced inside the SDK. Avoid reference cycles by using [weak self]

Sample

or
or

How to resume the latest process

You can resume the most recently started process using continueLatestProcess. This method uses the internally tracked latest process instance UUID.
  • name - the name of the process
  • navigationController - the instance of UINavigationController which will hold the process navigation stack
  • isModal - a boolean indicating whether the process navigation is modally displayed

Sample

How to end a process

You can manually end a process by calling the stopProcess(name: String) method. This is useful when you want to explicitly ask the FlowX shared instance to clean up the instance of the process sent as parameter. For example, it could be used for modally displayed processes that are dismissed by the user, in which case the dismissRequested(forProcess process: String, navigationController: UINavigationController) method of the FXDataSource will be called.

Sample

FXDataSource

The library offers a way of communication with the container app through the FXDataSource protocol. The data source is a public property of FlowX shared instance. public weak var dataSource: FXDataSource?
  • func controllerFor(componentIdentifier: String) -> FXController?
This method is used for providing a custom component using UIKit UIViewController, identified by the componentIdentifier argument.
  • func viewFor(componentIdentifier: String) -> FXView?
This method is used for providing a custom component using UIKit UIView, identified by the componentIdentifier argument.
  • func viewFor(componentIdentifier: String, customComponentViewModel: FXCustomComponentViewModel) -> AnyView?
This method is used for providing a custom component using SwiftUI View, identified by the componentIdentifier argument. A view model is provided as an ObservableObject to be added as @ObservedObject inside the SwiftUI view for component data observation.
  • func navigationController() -> UINavigationController?
This method is used for providing a navigation controller. It can be either a custom UINavigationController class, or just a regular UINavigationController instance themed by the container app.
  • func errorReceivedForAction(name: String?)
This method is called when an error occurs after an action is executed.
  • func validate(validatorName: String, value: Any, params: [String]?) -> Bool
This method is used for custom validators. It provides the name of the validator, the value to be validated, and an optional array of parameter strings. The method returns a boolean indicating whether the value is valid or not.
  • func dismissRequested(forProcess process: String, navigationController: UINavigationController)
This method is called, on a modally displayed process navigation, when the user attempts to dismiss the modal navigation. Typically it is used when you want to present a confirmation pop-up. The container app is responsible with dismissing the UI and calling the stop process APIs.
  • func viewForStepperHeader(stepViewModel: StepViewModel) -> AnyView?
This method is used for providing a custom SwiftUI view for the stepper navigation header.
  • func collect(event: AnalyticsEvent)
This method is used for collecting analytics events from the SDK. The parameter is a AnalyticsEvent enum, which can represent a screen or an action.
  • func newProcessStarted(processInstanceUuid: String)
This method is used for handling the start of another main process as a result of a START_PROJECT action. The parameter is the uuid of the process instance. The container app is responsible for dismissing the navigation of the current process and displaying the new process navigation.
  • func customLoader(type: CustomLoaderType) -> AnyView?
This method is used for providing a custom loader view. It is called by the SDK when a loading indicator needs to be displayed. The type parameter indicates the context in which the loader is shown. Return nil to use the default loader. This method has a default implementation that returns nil.
  • startProcess - the loader is displayed when a process is being started
  • reloadProcess - the loader is displayed when a process is being reloaded
  • action(String?) - the loader is displayed when an action is being executed. The associated value is the action name, if available.
  • upload(String?) - the loader is displayed for an in-progress file upload. The associated value is the action name, if available.

Sample

Custom components

FXController

FXController is an open class subclassing UIViewController, which helps the container app provide full custom screens the renderer. It needs to be subclassed for each custom screen.
Use this only when the custom component configured in the UI Designer is the root component of the User Task node.
  • internal(set) public var data: Any?
data is the property, containing the data model for the custom component. The type is Any, as it could be a primitive value, a dictionary or an array, depending on the component configuration.
  • internal(set) public var actions: [ProcessActionModel]?
actions is the array of actions provided to the custom component.
  • func titleForScreen() -> String?
This method is used for setting the screen title. It is called by the renderer when the view controller is displayed.
  • func populateUI()
This method is called by the renderer, after the controller has been presented, when the data is available. This will happen asynchronously. It is the container app’s responsibility to make sure that the initial state of the view controller does not have default/residual values displayed.
  • func updateUI()
This method is called by the renderer when an already displayed view controller needs to update the data shown.

FXView

FXView is a protocol that helps the container app provide custom UIKit subviews to the renderer. It needs to be implemented by UIView instances. Similar to FXController it has data and actions properties and a populate method.
  • var data: Any?
data is the property containing the data model for the custom view. The type is Any, as it could be a primitive value, a dictionary or an array, depending on the component configuration.
  • var actions: [ProcessActionModel]?
actions is the array of actions provided to the custom view.
  • func populateUI()
This method is called by the renderer after the screen containing the view has been displayed. It is the container app’s responsibility to make sure that the initial state of the view does not have default/residual values displayed.
It is mandatory for views implementing the FXView protocol to provide the intrinsic content size.

SwiftUI Custom components

Custom SwiftUI components can be provided as type-erased views. FXCustomComponentViewModel is a class implementing the ObservableObject protocol. It is used for managing the state of custom SwiftUI views. It has two published properties, for data and actions. It also includes a saveData dictionary and a validate closure used for submitting and validating data from the custom components.
Example

Validating SwiftUI Custom Components

A SwiftUI Custom Component can validate and submit data from a custom component, when executing an action from a FlowX.AI UI Component.
  • public var saveData: [String: Any]? Used for setting data to be submitted from the custom component.
  • public var validate: (() -> Bool)? Used for validating the custom component data before executing the action.

Sample

Custom header view for Stepper navigation

The container application can provide a custom view that will be used as the stepper navigation header, using the FXDataSource protocol method viewForStepperHeader. The method has a parameter, which provides the data needed for populating the view’s UI.

Sample

How to run an action from a custom component

The custom components which the container app provides will contain FlowX actions to be executed. To run an action you need to call the following method:
action - the ProcessActionModel action object params - the parameters for the action

How to run an upload action from a custom component

action - the ProcessActionModel action object image - the image to upload
action - the ProcessActionModel action object fileURL - the local URL of the file

Getting a substitution tag value by key

All substitution tags will be retrieved by the SDK before starting the first process and will be stored in memory. Whenever the container app needs a substitution tag value for populating the UI of the custom components, it can request the substitution tag using the method above, providing the key.

Getting a media item url by key

All media items will be retrieved by the SDK before starting the first process and will be stored in memory. Whenever the container app needs a media item url for populating the UI of the custom components, it can request the url using the method above, providing the key.

Getting enumeration values

The SDK provides two methods for fetching enumeration values, an async/await version and a callback version.
  • name - the name of the enumeration to retrieve
  • parentName - the parent enumeration name, if the enumeration is a child. Pass nil for root enumerations.
  • completion - a closure called with the array of enumeration items, or nil if not found (callback version only)
The method first checks the local cache and returns cached items if available. If not cached, it fetches the enumeration from the server.

EnumerationItem

Sample

Collecting analytics events

To collect analytics events from the SDK, the collect(event: AnalyticsEvent) func of the FXDataSource protocol needs to be implemented. The func will be called by the SDK each time a screen or an action analytics event occurs. The type of the event and relevant metadata are included in the func parameter event which is a AnalyticsEvent enum case.
The value property represents the identifier set in the process definition.Both screen and action events include an optional customPayload dictionary for additional custom data configured in the process definition.For action type events there are some additional properties provided:
  • component - The type of component triggering the action
  • label - The label of the component, if available. (E.g. title of a button or label of a form element)
  • screen - The identifier of the screen containing the component, if set

Handling authorization token changes

When the access token of the auth session changes, you can update it in the renderer using the func updateAuthorization(token: String) method.
Last modified on July 15, 2026