I want to create interactive widget. It should have a button which, once pressed makes a http request. (actually switches on the preconditioniong of my car)
I used so far the url which calls the same script with a parameter:
"scriptable:///run?scriptName=Test&action=switchAirconOn"
It works, I can evaluate the parameter. However it reloads the widget again. Is there any possibility to have interactions within a widget?
Edit: I made a small video to demonstrate the behavior… opening the scriptable app is not really what I want: https://spider.li/interactive_script.mp4
You can use any URL, so why not the one to “make a http request”?
It needs a login. This “one” http requests consists of 4 single requests with some logic. Sorry for simplifying the problem to much.
So I’ve achieved something similar. What you can do is something like this:
if (args.queryParameters.action) {
if (args.queryParameters.action === 'switchAirconOn') {
await methodToSendRequest()
}
//cancel rest of script and return to the homescreen
Safari.open('shortcuts://x-callback-url/run-shortcut?name=SpringBoard')
Script.complete()
}
Running the SpringBoard shortcut will return you to the home screen (via a brief jump to the shortcuts app).
You can get the springboard shortcut here: https://routinehub.co/shortcut/2900/
You could create a shortcut to update your widget and then run SpringBoard if you need your widget to update when you click a “widget button”. You’d just want to update the x-callback name parameter to whatever your shortcut is called.
1 Like
Thanks very much, you saved the day
Its a work around, but it works perfectly. The jump to shortcuts is not a problem at all, the jump to the scriptable is worse since it always takes some time to execute this command. I wish scripts could run in background.