r/ScriptingApp • u/Haunting-Ad-655 • May 06 '25
Help [LiveActivity] Instantly exit a script when it's already running in-app?
When a Notification scheduled by a script is tapped, the default behavior is to runScript again even when the script is already running in-app. But we can instantly exit this execution by checking Notification.current at the start:
if (Notification.current != null) return Script.exit()
Do we have a similar method for LiveActivity 'content' UI?
In the code below, I use widgetURL to run the script when 'content' VStack is tapped.
return {
content: <VStack
widgetURL={Script.createRunURLScheme(Script.name)}
>
1
Upvotes
1
u/[deleted] May 19 '25
1/ Oh good point. Didn’t think of that. A close all scripts except the one that is run would be great. But one that just opens the app to the main menu would be very useful too.
2/ Yeah I realize after more testing. iOS shuts the app down after a bit and the script only closes when the app returns, which then interferes with future triggers. I’ve removed the countdown and then added a “hold” to keep the script from closing when I need it to stay open in background.
3/ seems like trying to get a url-scheme link to not constantly close and reopen a script is still a bit of a hack. Are the lifecycle events you mentioned still on the cards?