AppShortcut能在快捷指令应用中看到,但在Spotlight搜索中却看不到

移动开发 2026-07-09

我想创建我自己的应用快捷方式,这样就能在Spotlight中搜索到我的应用及其内容。目前我有这些代码:

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()
        }
...
}

这个快捷方式会出现在快捷指令应用中。但当我用Spotlight进行搜索时,它并不会显示。我该如何让它在Spotlight中显示?

谢谢。

解决方案

要让它在操作系统层面、超出你的应用和快捷指令应用之外显示,你需要将快捷方式捐赠给Siri。

以下是文档:https://developer.apple.com/documentation/SiriKit/donating-shortcuts

请注意,在与用户交互相关的场景中捐赠快捷方式时效果最好;系统会对这些给予更高的优先级。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章