我目前正在创建一个App应该通过 AppIntent 启动的项目。例如,每当我打开Instagram时,它都应该触发 AppIntent,然后由 AppIntent 决定我的应用程序是否应该打开。第一部分已经可以通过 Apple Shortcuts 正常工作。问题是动态打开或不打开我的App. 不幸的是 openAppWhenRun 字段应该是静态的并且不能在运行时计算。
这是到目前为止的 AppIntent:
struct OpenTimeEfficientIntent: AppIntent {
static var title: LocalizedStringResource = "Opens the app conditionally"
static var openAppWhenRun: Bool = false
@Parameter(title: "OpenedApp", optionsProvider: Provider())
var app: String //this is the initially opened app e.g. Instagram (i want to pass it)
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
//at this point I want to …Run Code Online (Sandbox Code Playgroud)