Process data from onboardings in iOS SDK
When your users respond to a quiz question or input their data into an input field, the onStateUpdatedAction method will be invoked. You can save or process the field type in your code.
For example:
func onboardingController(_ controller: AdaptyOnboardingController, onStateUpdatedAction action: AdaptyOnboardingsStateUpdatedAction) {
// Store user preferences or responses
switch action.params {
case .select(let params):
// Handle single selection
case .multiSelect(let params):
// Handle multiple selections
case .input(let params):
// Handle text input
case .datePicker(let params):
// Handle date selection
}
}
The action object contains:
| Parameter | Description |
|---|---|
elementId | A unique identifier for the input element. You can use it to associate questions with answers when saving them. |
params | The user's input data object containing type and value properties. |
params.type | The type of input element. Can be: • "select" - Single selection from options• "multiSelect" - Multiple selections from options• "input" - Text input field• "datePicker" - Date selection |
params.value | The value(s) selected or entered by the user. Structure depends on type: • select: Object with id, value, label• multiSelect: Array of objects with id, value, label |