I’ve carried out 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 .consequence()
}
}
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, type: .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 carried out utilizing @Parameter
, however after that it’s not working.
However in actual gadget it’s immediately opening the app and never calling the standards. And displaying error in console Did not generate TargetContentIdentifier for standards
.
Official Documentation url Apple Developer
That is the complete code I’ve carried out. Please discover the answer.