App Shortcuts: Invalid parameter type. AppEntity and AppEnum are the only allowed types...

Hi!

So while Date is supported for @Parameter in an App Intent, I just discovered that Xcode will not let me use use it in a parametrized App Shortcut phrase.

In my case, I would like to give the option to say "today", tomorrow", or "day after tomorrow" for the date. Am I missing something? Any hints on the best way to approach this?

Got any code we might be able to look at and see how we can help?

@darkpaw the following code is giving me the above error:

struct GetIntent: ForegroundContinuableIntent {
    ...
    @Parameter
    var date: Date?
    ...
}

...

class MyShortcuts: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: GetIntent(),
            phrases: [
                "Get \(.applicationName) for \(.date)"
            ],
            shortTitle: "Get",
            systemImageName: "calendar")
    }
}
Accepted Answer

In my case, I would like to give the option to say "today", tomorrow", or "day after tomorrow" for the date.

Is date relativity always your expected use? These could become AppEnums instead, and then you convert the relative value into a Date when the intent runs. But if you also expect specific dates, that isn't possible with an App Shortcut, because the parameters in an App Shortcut invocation phrase can't be open ended — which is why the closed set nature of an AppEnum is a good choice if you're only expecting relative date values.

—Ed Ford,  DTS Engineer

Thanks for the clarification. So looks like the solution would be to use an AppEnum with the AppShortcut and potentially have another AppIntent with a Date parameter not exposed as an AppShortcut for use in automations I guess?

If you really need to have an intent with the Date parameter, that suggestions will work.

—Ed Ford,  DTS Engineer

I have the same issue. Since I am using the FoundationModels to process the user question, I cannot use AppEnum. The user experience where they have to first say "Ask <app_name>" and then ask their question is bad.

What's the solution in this case? I want it to be like "Siri, ask chatGPT <question>"

App Shortcuts: Invalid parameter type. AppEntity and AppEnum are the only allowed types...
 
 
Q