I feel like this is probably really easy and hopefully I'm just doing something stupid, but I can't get a control to open the app it belongs to.
Taking the intent itself directly from the example code, and it does nothing when the button is pressed.
struct OpenAppWidget: ControlWidget {
var body: some ControlWidgetConfiguration {
StaticControlConfiguration(
kind: "com.dfjkldfsfrw.ControlCenterWidgetDemo.OpenApp"
) {
/// This one - based on the demo code - doesn't work on simulator or device
ControlWidgetButton(action: LaunchAppIntent()) {
Label("Launch App", systemImage: "arrow.up.right")
}
}
.displayName("Launch App")
.description("A an example control that launches the parent app.")
}
}
struct LaunchAppIntent: OpenIntent {
static var title: LocalizedStringResource = "Launch App"
@Parameter(title: "Target")
var target: LaunchAppEnum
}
enum LaunchAppEnum: String, AppEnum {
case timer
case history
static var typeDisplayRepresentation = TypeDisplayRepresentation("Productivity Timer's app screens")
static var caseDisplayRepresentations = [
LaunchAppEnum.timer : DisplayRepresentation("Timer"),
LaunchAppEnum.history : DisplayRepresentation("History")
]
}
I've tried adding a perform(
function to the intent, and setting openAppWhenRun
to true, but they don't seem to make a difference.
I've also tried using an OpenURLIntent
in the result of the button's intent to open the app based on a custom url scheme, but whilst that seems to work in the simulator, it doesn't work on a real device.
What am I missing?