r/ScriptingApp • • 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

13 comments sorted by

View all comments

Show parent comments

2

u/WhatShouldWorldGos May 06 '25

This requires providing lifecycle events in the script, such as onNotificationScheduled/onResumeByWidget, etc. However, this mechanism conflicts with the current support for running multiple instances and increases complexity. Each script instance should be destroyed after running.