HomeiOS Developmentios - Disambiguation for .system.search AppIntent

ios – Disambiguation for .system.search AppIntent


I might wish to show an inventory of things to disambiguate for a fulltext search intent. Utilizing the Apple AppIntentsSampleApp, I added TrailSearch.swift:

import AppIntents

@out there(iOS 18.0, *)

@AssistantIntent(schema: .system.search)
struct TrailSearch: AppIntent {
    static let title: LocalizedStringResource = "Search Path"
    static let description = IntentDescription("Search path by identify.",
                                               categoryName: "Uncover",
                                               resultValueName: "Path")
 
    @Parameter(title: "Path")
    var standards: StringSearchCriteria
    
    func carry out() async throws -> some IntentResult & ReturnsValue {
        if standards.time period.isEmpty {
            throw $standards.needsValueError(IntentDialog("want worth"))
        }
        let trails = TrailDataManager.shared.trails { path in
            path.identify.comprises(standards.time period)
        }
        if trails.depend > 1 {
            throw $standards.needsDisambiguationError(amongst: trails.map { StringSearchCriteria(time period: $0.identify) })
        } else if let firstTrail = trails.first {
            return .consequence(worth: TrailEntity(path: firstTrail))
        }
        throw $standards.needsValueError(IntentDialog("Nothing discovered"))
    }
}

Now after I sort “path” which matches a number of trails and thus lets us enter the disambiguation code path, the Shortcut app simply shows the dialog title however no disambiguation objects to choose from.

Is there something incorrect with my code?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments