I have a Personal Automation that runs a shortcut daily @ 7pm. When the automation runs, my phone is typically locked. The end of the shortcut passes a fillename to a scriptable script. If this file exists, the script will move the file from one iCloud Documents bookmark to another. When I run this shortcut manually, everything works fine, but when executed via the automation, everything works except the file is not moved.
Is scriptable’s Filemanager.move() permitted to work when the phone is locked?
Is your script running inline in Shortcuts, or is it jumping out to the Scriptable app?
If the former, maybe set up a test to move a file that doesn’t rely on bookmarks. I’m wondering if it could be the bookmarks aspect that requires deeper access to Scriptable and might not be available to Shortcuts when the device isn’t unlocked.
I would have tested it myself for you, but I’m about to head off and prepare lunch for the family.
As you probably know, iOS apps are limited to where they can write files. For example the short cuts app can only write to iCloudDrive/Shortcuts/ . Scriptable has similar restrictions, but using Bookmarks, you can get around this.
Regarding how the short cut works, yes - it does have an action that launches a Scriptable script via the action that is provided by the scriptable app
Today, I happened to be using the phone when the shortcut ran, and it worked without issue.
Do you have that action set to run in app?
No. Both that and ‘Show When Run’ are off. I know the script is running and making it past the validation ensuring that the source file exists from some debug notifications I added.
So as a quick check, I created a similar automation that is triggered from an NFC tag. When the phone is locked (but the screen on), I see the same behavior. However, I also noticed there is a “Tap to respond” notification from scriptable. If I tap on this (after unlocking the phone), the shortcut/script complete as desired. As a last step, I will, as @sylumer suggested, create a test scenario where the file move happens within the Scriptable sandbox and/or see if anything changes with the FileManager.copy() method instead.
FWIW - I also tried using FileManager.local() and using the .copy() method. In all cases when running the shortcut when locked, has the same effect. Also, tried making the script run “in app” - no change. In doing some of this, I see the same “Tap to respond” notification from Scriptable. So when the phone is locked, I actually cannot get any script to run (when launched via an NFC automation).
Conclusion - the problem seems to have nothing to do with being on the lock screen per-se. it has to do with the device being locked. In this case the scriptable scripts cannot execute. So I will have to re-think the automation I am attempting to execute
“Tap to respond” has come up a few times here and on Reddit too. It looks to have dipped in and out during the beta and finally settled as ‘in’. It appears to be part of Apple’s current security constraints.
If you search for this phrase, you can see that it affects other apps too, including some actions for Apple’s own apps.