ios – AppIntents and AppShortcutsProvider Not Working utilizing Siri voice in Swift

0
17
ios – AppIntents and AppShortcutsProvider Not Working utilizing Siri voice in Swift


I’ve applied ShowInAppSearchResultsIntent and AppShortcutsProvider that’s newly launched by apple in WWDC24.

import AppIntents
import Basis
import UIKit

@AssistantIntent(schema: .system.search)
struct CineverseSearchIntent: ShowInAppSearchResultsIntent {
//    static var title: LocalizedStringResource = "Search in Cineverse for"
    static var searchScopes: [StringSearchScope] = [.general]
    
    @Parameter(requestValueDialog: IntentDialog("What would you wish to seek for?"))
    var standards: StringSearchCriteria
    
    @MainActor
    func carry out() async throws -> some IntentResult {
        let searchString = standards.time period
        print("Trying to find (searchString)")
        msgWithSingleButton(message: "Trying to find (searchString)", title: "Siri", buttonTitle: "OK")
        return .end result()
    }
}

class AppShortcuts: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: CineverseSearchIntent(),
            phrases: [
                "using (.applicationName) search for",
                "search on (.applicationName) app"
            ],
            shortTitle: "Search Film",
            systemImageName: "sparkles"
        )
    }
}

//Alert
func msgWithSingleButton(message: String, title: String = "",buttonTitle : String){
    let alertView = UIAlertController(title: title, message: message, preferredStyle: .alert)
     alertView.addAction(UIAlertAction(title: buttonTitle, model: .default, handler: nil))
    let scenes = UIApplication.shared.connectedScenes
        let windowScene = scenes.first as? UIWindowScene
        let window = windowScene?.home windows.first
    window?.rootViewController?.current(alertView, animated: true)
}

I’ve tried the above code. It’s triggering the standards in simulator(iOS 18.0). Siri is saying the phrase – “What would you wish to seek for?” – that i’ve applied utilizing @Parameter, however after that it’s not working.
However in actual system it’s immediately opening the app and never calling the standards. And exhibiting error in console Did not generate TargetContentIdentifier for standards.

Official Documentation url Apple Developer

That is the complete code I’ve applied. Please discover the answer.

LEAVE A REPLY

Please enter your comment!
Please enter your name here