settings.gradle.kts
file:app/build.gradle.kts
file:FlowxSdkApi
singleton instance, which exposes the following methods:
Name | Description | Definition |
---|---|---|
init | Initializes the FlowX SDK. Must be called in your application’s onCreate() | fun init(context: Context, config: SdkConfig, customComponentsProvider: CustomComponentsProvider? = null) |
checkRendererCompatibility | Checks the renderer version compatibility with the deployed services | suspend fun checkRendererCompatibility(action: ((Boolean) -> Unit)?) |
startProcess | Starts a FlowX process instance, by returning a @Composable function where the process is rendered. | fun startProcess(processName: String, accessToken: String, params: JSONObject = JSONObject(), isModal: Boolean = false, closeModalFunc: ((processName: String) -> Unit)? = null): @Composable () -> Unit |
continueProcess | Continues an existing FlowX process instance, by returning a @Composable function where the process is rendered. | fun continueProcess(processUuid: String, accessToken: String, isModal: Boolean = false, closeModalFunc: ((processName: String) -> Unit)? = null): @Composable () -> Unit |
executeAction | Runs an action from a custom component | fun executeAction(action: CustomComponentAction, params: JSONObject? = null) |
getMediaResourceUrl | Extracts a media item URL needed to populate the UI of a custom component | fun getMediaResourceUrl(key: String): String? |
replaceSubstitutionTag | Extracts a substitution tag value needed to populate the UI of a custom component | fun replaceSubstitutionTag(key: String): String |
updateAccessToken | Updates the access token inside the renderer | fun updateAccessToken(token: String) |
onCreate()
method:
Name | Description | Type | Requirement |
---|---|---|---|
context | Android application Context | Context | Mandatory |
config | SDK configuration parameters | ai.flowx.android.sdk.process.model.SdkConfig | Mandatory |
customComponentsProvider | Provider for the @Composable /View custom components | ai.flowx.android.sdk.component.custom.customComponentsProvider? | Optional. Defaults to null . |
custom components
implementation is explained in its own section.
SdkConfig
data for the config
parameter above are:
Name | Description | Type | Requirement |
---|---|---|---|
baseUrl | URL to connect to the FlowX back-end environment | String | Mandatory |
imageBaseUrl | URL to connect to the FlowX Media Library module of the CMS | String | Mandatory |
language | The language used for retrieving enumerations and substitution tags | String | Optional. Defaults to en . |
validators | Custom validators for form elements | Map<String, (String) -> Boolean>? | Optional. |
themeTokensJsonFileAssetsPath | Android assets relative path to the theme tokens json file | String? | Optional. When null internal theme will be used. |
themeComponentsJsonFileAssetsPath | Android assets relative path to the theme components json file | String? | Optional. When null internal theme will be used. |
custom validators
map is a collection of lambda functions, referenced by name (i.e. the value of the key
in this map), each returning a Boolean
based on the String
which needs to be validated.
For a custom validator to be evaluated for a form field, its name must be specified in the form field process definition.
By looking at the example from above - mapOf("exact_25_in_length" to { it.length == 25 })
- if a form element should be validated using this lambda function, in the process definition it must specifiy a custom validator named "exact_25_in_length"
.
themeTokensJsonFileAssetsPath
and themeComponentsJsonFileAssetsPath
parameters should contain some values, representing Android assets relative paths to the corresponding JSON file for tokens and components.file://android_asset/...
, where ...
is the relative path within your project’s assets/
directory.
suspend
function checkRendererCompatibility
:
startProcess
function:
Parameter | Description | Type | Requirement |
---|---|---|---|
processName | The name of the process | String | Mandatory |
accessToken | The access token which allows access to the FlowX backend services | String | Mandatory |
params | The starting params for the process, if any | JSONObject | Optional. If omitted, if defaults to JSONObject() |
isModal | Flag indicating whether the process can be closed at anytime by tapping the top-right close button | Boolean | Optional. It defaults to false . |
closeModalFunc | Lambda function where you should handle closing the process when isModal flag is true | ((processName: String) -> Unit)? | Optional. It defaults to null . |
@Composable
returned from the SDK (i.e. it occupies the whole activity screen space).
continueProcess
function:
Parameter | Description | Type | Requirement |
---|---|---|---|
processUuid | The UUID string of the process | String | Mandatory |
accessToken | The access token which allows access to the FlowX backend services | String | Mandatory |
isModal | Flag indicating whether the process can be closed at anytime by tapping the top-right close button | Boolean | Optional. It defaults to false . |
closeModalFunc | Lambda function where you should handle closing the process when isModal flag is true | ((processName: String) -> Unit)? | Optional. It defaults to null . |
@Composable
returned from the SDK (i.e. it occupies the whole activity screen space).
updateAccessToken
method:
componentIdentifier
configured in the UI designer.CustomComponentsProvider
interface should be passed as a parameter when initializing the SDK:
CustomComposableComponent
interface:
CustomComposable
object is an interface defined like this:
CustomViewComponent
interface:
CustomView
object is an interface defined like this:
executeAction
method:
Name | Description | Type | Requirement |
---|---|---|---|
action | Action object extracted from the data received in the custom component | ai.flowx.android.sdk.component.custom.CustomComponentAction | Mandatory |
params | Parameters needed to execute the action | JSONObject? | Optional. It defaults to null |
key
.
It returns:
key
is valid and foundkey
is valid, but not found@@
)key
.
It returns the URL
string of the media resource, or null
, if not found.