iOS18 Control Widget that opens parent app

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?

I have no idea how this works either! Apple Engineers please give us a detailed explanation or same code.

onOpenURL does not pass the url scheme either

Submitted feedback with ID: FB14876696

This question has been posted previously, and the "solution" is posted here: https://developer.apple.com/forums/thread/758637

Right now, for the parent app to open, you need to check the target membership box of your AppIntent file so that it lives in both the parent app and the control extension / widget bundle.

Apple has not clarified the reason why this is, and I'd love to more too, but for now this is the only way that seems to work. I hope this behavior is adjusted / fixed before release.

Further reading: https://developer.apple.com/forums/thread/759794

iOS18 Control Widget that opens parent app
 
 
Q