最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - App Shortcut Not Appearing When Using Parameter in Phrase - Stack Overflow

programmeradmin3浏览0评论

Why doesn't my App Shortcut appear in Shortcuts when using a parameter, but it works when I remove the parameter?

class AppShortcuts: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: ConnectIntent(),
            phrases: [
                "Call \(\.$name) in \(.applicationName)"
            ],
            shortTitle: "Call",
            systemImageName: "sparkles"
        )
    }
}

However, when I remove the parameter, it appears in Shortcuts:

class AppShortcuts: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: ConnectIntent(),
            phrases: [
                "Call in \(.applicationName)"
            ],
            shortTitle: "Call",
            systemImageName: "sparkles"
        )
    }
}

Intent:

struct ConnectIntent: AppIntent {
    static var title: LocalizedStringResource = "Call"
    
    @Parameter(title: "name")
    var name: String
    
    func perform() async throws -> some IntentResult & ProvidesDialog {
        
            try await CallerService.shared.call(selectedName: name)
            return .result(dialog: "Calling now")
        
    }
}
发布评论

评论列表(0)

  1. 暂无评论