4

I am building a PWA application that works like a pomodoro clock. So it counts down 25 minutes and informs the user when the time is up.

I was thinking of several solutions. - When the PWA application starts it sets the alarm built into the phone - The PWA app runs in the background all the time, and it triggers its own alarm.

My application keeps data in a realtime database in firebase about when the timer will end. So I was thinking about using the firebase function that checks how much time is left, but it's probably not possible because the functions are quickly lost.

I am also thinking about a separate back end that would check if the time has already elapsed and send a push notification to the phone but I do not know how to go about it and whether it will be a good solution.

I would like the application PWA to inform the user when the time runs out. Especially when it is turned off. For example, by notification or alarm. What tool can I use to make it possible (getting notifications / beep sound when the time is up)?

Szymon Brud
  • 117
  • 1
  • 6
  • 1
    FYI, this is a too broad question. Reread [ask] and [help/on-topic] how and what is not. – Asons Oct 04 '19 at 17:48
  • To everyone who wants this functionality, please star and comment on the Google issue requesting it to motivate them to act: https://bugs.chromium.org/p/chromium/issues/detail?id=889077 – Richard Jun 09 '22 at 08:50
  • Does this answer your question? [Background events in progressive web apps? (building an alarm clock app)](https://stackoverflow.com/questions/36944167/background-events-in-progressive-web-apps-building-an-alarm-clock-app) – gre_gor Dec 22 '22 at 20:33

1 Answers1

5

'Setting background timers isn't yet possible. The ScheduledTask API is probably do what you want, but it's still being discussed, implemented and so on.'

Refer Background events in progressive web apps? (building an alarm clock app).

Sudhakar Ramasamy
  • 1,736
  • 1
  • 8
  • 19
  • Set timeout works well if the PWA keeps open in the foreground. Making use of fact that AMOLED screen turned off when showing black color, we can just show a blank black screen and keep the screen awake using WakeLock API. I've tried it by using 20m using setTimeout, it works. Doesn't drain much energy too. – tmpmachine Mar 13 '23 at 12:44