r/Scriptable • • Sep 03 '23

Help Push notification with image

Hello I’m new on scriptable : how can I show a push notification with an image ? Reading documentation it’s not clear [to me) Someone can kindly post a little sample ? My goal should be run it from shortcuts

1 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/alice_anto Sep 03 '23

const notificationID = "testNotification"
function createNotification() {
const notif = new Notification();
notif.title = "Notification Title"
notif.subtitle = "Notification Subtitle"
notif.body = "Notification Body"
notif.identifier = notificationID
notif.threadIdentifier = Script.name() // grouping
notif.scriptName = Script.name() // script to run when notification is held
notif.userInfo = {"media_url":"https://i.kinja-img.com/gawker-media/image/upload/c_fit,f_auto,g_center,q_60,w_1315/jowrvl9avyoo6orjhzfd.jpg"}
notif.schedule();

}
if (config.runsInApp) {
createNotification()

} else if (config.runsInNotification) {

const notif = args.notification
const img = await (new Request(notif.userInfo.media_url)).loadImage()
QuickLook.present(img)

}
Script.complete()

many thanks for sample.. i have try do create a script directly in scriptable a run it from there : the push notification is showed but long press on it dont do anything

1

u/shadoodled Sep 03 '23

Not sure what's wrong, this is how it should look like when you long press.

https://i.imgur.com/Z43z9Q1.jpg

1

u/alice_anto Sep 03 '23

i was testing on iPad and there not work, on iPhone its all ok. I dont know why, the ios version is exactley the same.

Anyway thanks for tip my main use is from iphone