Skip to main content
Version: 4.59

askUser

Shows a modal pop-up with buttons in the style of the operating system. The lists of buttons and events or actions reference each other so that the button with a specific index will trigger the corresponding event or action with the same index.

note

If no buttons are defined, an "OK" is displayed by default to confirm and close the modal pop-up.

Field Configurations

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters

KeyTypeDescriptionDefault Value
"actions"ArrayA list of actions that are fired when the button with the same index is clicked.null
"async"BooleanSpecifies whether the action should perform asynchronously.null
"buttons"ArrayA list of texts that are displayed as buttons.null
"events"ArrayA list of events that are fired when the button with the same index is clicked.null
"isCancelable"Boolean,StringIndicates whether the pop up can be closed by clicking outside the pop up or via the Back button.false
"message"StringThe text of the pop up.null
"onCancel"StringThis event is fired on cancellation.null
"title"StringThe title of the pop up.null

Inherited

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples

Example 1: Create an askUser action using events

Goal: Create an askUser action with two options and correlating events.

In this case, the event nothingPicked is fired on cancellation.

{
"type": "askUser",
"params": {
"title": "Leave the Matrix?",
"message": "Take a pill",
"isCancelable": true,
"onCancel": "nothingPicked",
"buttons": [
"Red Pill",
"Blue Pill"
],
"events": [
"pickedRed",
"pickedBlue"
]
}
}

The button list can contain simple strings or objects with the fields:

  • label: text on the button
  • image: image on the left side of the button

Result:

Screencapture of the app showing the results of the sample code from Example 1.

Example 2: Create an askUser action using actions

Goal: Create an askUser action with two options and correlating actions.

The actions are placed in an array of arrays.

{
"type": "askUser",
"params": {
"title": "An error occured",
"message": "Do you want to report the error?",
"isCancelable": true,
"onCancel": "nothingPicked",
"buttons": [
"Yes",
"No"
],
"actions": [
[
{
"type": "backInHistory",
"params": {
"steps": "-1"
}
},
{
"type": "mailTo",
"params": {
"to": "support@mail.com",
"subject": "Feedback: Error report",
"content": ""
}
}
],
[
{
"type": "backInHistory",
"params": {
"steps": "-1"
}
}
]
]
}
}

More than one action can be tied to each button.

Result:

An askUser action has been created.