Notification while working in the background

Is there a way to show a notification while the script started a download from the cloud - and kill the notification when ready and back from download?

You could show a notification and then continue showing that notification again and again as the script runs until the download finishes, then dismiss them.

Would that work? I’m imagining a whole loop running while downloading and when it finished then it would stop and could remove the notifications at that point in time

Thank you for your fast response - I have a question though:

The download happens via the downloadFileFromiCload method of the File Manager - so there is no looping. Would work to send out the notification before that command and dismiss it afterwards ?

Would it not be better to post a notification to indicate the download starting, and then a subsequent separate second notification to indicate the download ending?

They are separate events and it sounds like you are not doing this utilising a UI where you could incorporate on screen info (typically a status bar if you could monitor downloaded data volume). As such, a separate notification for each event makes sense to me, whereas a pervasivr/persistent notification would feel like an annoyance (to me).

1 Like

You have a valid point here.
I think it would even be enough to indicate that a download started (usually 3-5 sec).
I am unexperienced with notifications - so I do not know how deliver one immediately- seems it needs to be scheduled? Or am I thinking of the wrong way doing this? (Alerts have to be interacted with - I want to avoid that)

Here is a code snippet for notification:

let n = new Notification()
n.title = "Notification Test"
n.body = "body of notification"
n.schedule()

You are right that they have to be scheduled, however, if you don’t indicate a date / time, it just schedules and sends immediately.

Works like a flaw…

Thank you all very much!

1 Like