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

apple watch - DynamicOptionsProvider - does it work on watchOS? - Stack Overflow

programmeradmin2浏览0评论

I'm curious, why DynamicOptionsProvider is available on watchOS? Is there any way to present options to the user? For example in Emoji Rangers project that supports both watchOS and iOS:

struct EmojiRangerSelection: AppIntent, WidgetConfigurationIntent {
    
    static let intentClassName = "EmojiRangerSelectionIntent"
    
    static var title: LocalizedStringResource = "Emoji Ranger Selection"
    static var description = IntentDescription("Select Hero")
    
    @Parameter(title: "Selected Hero", default: EmojiRanger.cake, optionsProvider: EmojiRangerOptionsProvider())
    var hero: EmojiRanger?
    
    struct EmojiRangerOptionsProvider: DynamicOptionsProvider {
        func results() async throws -> [EmojiRanger] {
            EmojiRanger.allHeros
        }
    }
    
    func perform() async throws -> some IntentResult {
        return .result()
    }
}

On watchOS we usually use recommendations() to give the user predefined choice of configured widgets. Meanwhile in AppIntentProvider recommendations are empty:

struct AppIntentProvider: AppIntentTimelineProvider {
    ...
    func recommendations() -> [AppIntentRecommendation<EmojiRangerSelection>] {
        []
    }
}

Does it imply that there's a way to use DynamicOptionsProvider on watchOS somehow? BTW, WidgetConfiguration.promptsForUserConfiguration() is one of the methods that are not available on watchOS.

And also, the Emoji Ranger project doesn't show widgets (complications) on watchOS out of the box.

发布评论

评论列表(0)

  1. 暂无评论