Post

Replies

Boosts

Views

Activity

Reply to App Shortcuts with parameterized phrases not working
Hi @denrase @nokey4, I am trying to create a parameterized pharase like "Search {cap} in {applicaitonName}". Siri is not able to interpret it. I could not get the issue here. Also, it throws the following error in debug console while the test app is running - [Metadata] Failed to refresh Auto Shortcut parameter entities with error: Error Domain=LinkDaemon.Schema.RuntimeError Code=2 "(null)". struct SearchIntentShortcut: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: SearchIntent(), phrases: [ "Search \(\.$searchQuery) in \(.applicationName)" ]) } } struct SearchIntent: AppIntent { static var openAppWhenRun: Bool = true static var title: LocalizedStringResource = "Search In TestApp" @Parameter(title: "Search Term", optionsProvider: SearchTermOptionsProvider()) var searchQuery: SearchType? @MainActor func perform() async throws -> some ProvidesDialog { let searchTerm: SearchType if let searchQuery = searchQuery { searchTerm = searchQuery print(" Here is the spoken query \(searchTerm.term)") } else { searchTerm = try await $searchQuery.requestDisambiguation( among: SearchType.all, dialog: "What item would you like to search?" ) } return .result(dialog: "Searching \(searchTerm.term) in TestApp.") } } struct SearchType: AppEntity { let id: Int let term: String static var typeDisplayRepresentation = TypeDisplayRepresentation(stringLiteral: "Search term") var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: LocalizedStringResource("%@", defaultValue: String.LocalizationValue(term))) } static var defaultQuery = SearchItems() } struct SearchItems: EntityQuery { func entities(for identifiers: [SearchType.ID]) async throws -> [SearchType] { return SearchType.all.filter({ identifiers.contains($0.id) }) } func suggestedEntities() async throws -> [SearchType] { return SearchType.all } } extension SearchType { static let all = [ SearchType(id: 1, term: "shirt"), SearchType(id: 2, term: "cap") ] } private struct SearchTermOptionsProvider: DynamicOptionsProvider { func results() async throws -> [SearchType] { SearchType.all } }
Jul ’23