Contents

requestChoice(between:dialog:content:)

Pauses the app intent, asks the person to choose from the specified options, and provides additional content related to those options.

Declaration

func requestChoice<Content>(between options: [IntentChoiceOption], dialog: IntentDialog? = nil, @ViewBuilder content: () -> Content) async throws -> IntentChoiceOption where Content : View

Parameters

  • options:

    The options to choose from. The prompt displays the options in the same order they appear in the array, with one exception. If the list includes the Cancel option, the system places that option according to the platform’s conventions.

  • dialog:

    The localized text you want the system to display or speak. Provide instructional text or a question to help the person choose an option.

  • content:

    A closure that returns the view to display with the prompt. Use this closure to return a view with information to help someone make a decision.

Return Value

The option the person chose.

Discussion

Call this method from the perform() method of your app intent when you need someone to confirm an action, disambiguate from a set of possibilities, or select an intent-specific behavior before proceeding. The system displays a standard interface with the provided set of options and asks the person to choose one. When someone makes a selection, the method returns the option and your app intent continues to run. This method throws an error if someone cancels the request using a cancel button, a cancel option, or a system-provided gesture.

See Also

Requesting more information