I want to create my own AppShortcut so I can search for my app and its contents on Spotlight. Currently I have these codes:
import AppIntents
@available(iOS 16.0, *)
struct TransferIntent: AppIntent {
static var title = LocalizedStringResource("Transfer money.")
static var openAppWhenRun = true
static var isDiscoverable = true
func perform() async throws -> some IntentResult & ProvidesDialog {
NavigationManager.shared.navigate(to: .transferMoney)
return .result(dialog: IntentDialog("Open app to transfer money."))
}
}
import AppIntents
@available(iOS 16.0, *)
struct OmniAppShortcutsProvider: AppShortcutsProvider {
@AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: TransferIntent(),
phrases: [
"Transfer money with \(.applicationName)",
"Kirim uang dengan \(.applicationName)"
],
shortTitle: "Transfer money",
systemImageName: "banknote.fill"
)
}
}
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
setupAppsFlyer()
if #available(iOS 16.0, *) {
OmniAppShortcutsProvider.updateAppShortcutParameters()
}
...
}
The shortcut shows up on Shortcuts app. But when I tried searching with Spotlight, it doesn’t show up. How do I show it on Spotlight?
Thanks.
