Any plans to add notification actions/objects? In Shortcuts, I’ll sometimes display a notification at the end of a script; as far as I can tell, the closest I can come to that in Scriptable is an Alert (with a baked-in Cancel button; if there was an option to use an OK button instead, that would be an improvement).
If you don’t mind using IFTTT you could use a webhook there and make a HTTP (PUT) request in Scriptable to trigger a notification.
(I used this to test notifications)
I use PushOver https://pushover.net/. Its an app that you install on your phone. Then you can send notifications via a url request.
You can in fact show an OK button in alert. Something like the following should work.
let alert = new Alert()
alert.title = "My alert"
alert.message = "This is my alert."
alert.addAction("OK")
await alert.presentAlert()
That said, I am actively working on adding support for scheduling notifications from a script. If everything goes well, this will be included in the next update.
How can my code detect what i chose as option
The documentation explains you get the index rather than the value.
Here’s an example.
let alert = new Alert();
alert.title = "Selection Test";
alert.message = "Choose an option.";
alert.addAction("Foo");
alert.addAction("Bar");
alert.addAction("Quz");
alert.addAction("Qux");
let intIndex = await alert.presentAlert();
let strReturn;
switch(intIndex)
{
case 0:
strReturn = "Foo";
break;
case 1:
strReturn = "Bar";
break;
case 2:
strReturn = "Quz";
break;
case 3:
strReturn = "Qux";
break;
}
console.log("You chose option " +intIndex + ", " + strReturn);
It shows four options and writes details of the selection to the console.
Hope that helps.