How to create a interactive widget

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