IntentURLRepresentation
The type that provides the URL for an app intent.
Declaration
struct IntentURLRepresentation<Intent> where Intent : AppIntentOverview
If you adopt the URLRepresentableIntent protocol in an app intent, use this type to build the URL for your app intent. Construct the type as a Swift string that contains characters suitable for use in a URL. To incorporate content from your app intent’s parameters into the URL, include a key path to the parameter in your string. The following example provides the URL for a specific page of a website. Before returning the URL, this type replaces the \(\.$page) key path with the value in the page parameter.
struct OpenAppleDotCom: URLRepresentableIntent {
static var urlRepresentation: URLRepresentation = "https://www.apple.com/\(\.$page)"
@Parameter(title: "Page")
var page: String
static var title: LocalizedStringResource = "Open Apple website"
}Make sure the parameters you include in your URL representation contain a URL-friendly type. The system automatically converts parameters of type String, Int, and URL to values suitable for inclusion in a URL. To incorporate other types, implement the CustomURLRepresentationParameterConvertible protocol in the type.