You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AppShortcut在快捷指令App可见但Spotlight搜不到,如何使其显示

问题:自定义AppShortcut无法在Spotlight中搜索到

我想要创建自定义AppShortcut,以便在Spotlight中搜索我的应用及其内容。目前我使用以下代码,该快捷指令可在快捷指令App中显示,但在Spotlight中搜索却无法找到。请问如何让它在Spotlight中显示?

现有代码

TransferIntent.swift

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

OmniAppShortcutsProvider.swift

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"
        )
    }
}

AppDelegate.swift

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        
        setupAppsFlyer()
        
        if #available(iOS 16.0, *) {
            OmniAppShortcutsProvider.updateAppShortcutParameters()
        }
        // ...其他代码
        return true
    }
}

解决方法

  • 检查Spotlight权限设置:进入「设置」→「Siri与搜索」→ 找到你的应用,确保「在Spotlight中显示」和「允许Siri建议」选项已开启,同时确认「快捷指令」相关权限未被禁用。
  • 优化AppShortcut搜索短语:当前的短语都包含应用名称,用户在Spotlight搜索时可能不会输入应用名,建议添加更直接的搜索短语,比如:
    phrases: [
        "Transfer money with \(.applicationName)",
        "Kirim uang dengan \(.applicationName)",
        "Transfer money",
        "Kirim uang"
    ]
    
  • 补充Intent描述信息:给TransferIntent添加描述字段,帮助系统更好地索引内容:
    static var description = LocalizedStringResource("Transfer money between your accounts quickly.")
    
  • 等待系统索引或重启验证:AppShortcut的Spotlight索引可能存在延迟,尝试重启设备,或者卸载重装应用后再次测试。
  • 确认iOS版本兼容性:确保测试设备运行iOS 16.0及以上版本,且代码中的@available约束正确。

内容的提问来源于stack exchange,提问作者Bawenang Rukmoko Pardian Putra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.01 20:02:30