I'm using the App Intents API to provide an automation through the iOS Shortcuts app. When my intent runs, I'd like to be able to decide if I want to open the app (bring it to the foreground) or not. I know openAppWhenRun can be used to open the app, but its value cannot be modified.
I tried using openAppWhenRun, but it does not have a setter. Therefore, I cannot dynamically update this variable to determine if the app should be opened in the foreground or not.
Inside your intent's
perform-method, return.result(opensIntent:), opening another intent, that brings your app to the foreground. Should the conditions to do so not apply, you can throw a custom error (otherwiseperformwouldn't returnsome IntentResult). Just make sure your Error-enum adheres toCustomLocalizedStringResourceConvertible, so the user gets a useful message.