Skip to main content

askUser

Shows a modal pop up with buttons. The list of buttons and events are referencing each other, so the button on index n will trigger the event on the same index.

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

Goal: Create an askUser action with two options.

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.
An askUser action has been created.