patmood
patmood

Reputation: 1585

Keep phone screen on with PWA (progressive web app)

I built a fitness "progressive" web app that you can add to your phone home screen. It guides the user through a 7 minute workout.

Is there any way to keep the screen "awake" so the user doesn't have to keep coming back to the phone to turn it on? Another drawback to the screen sleeping is the javascript timer stops, ruining the workout timing.

Upvotes: 12

Views: 3463

Answers (1)

Simon Hyll
Simon Hyll

Reputation: 3608

https://www.w3.org/TR/wake-lock/

https://developer.mozilla.org/en-US/docs/Archive/B2G_OS/API/Wake_Lock_API

Basically, yes, there is such a thing as a website forcing the screen to stay awake, but it is non-standard currently. It may become standard but right now it seems to only work on FirefoxOS. This is however to be the intended way to achieve wake locking in javascript.

Another solution though that's more of a hack is doing something along the lines of playing a hidden video in the background since as far as i know most browsers stay awake if a video is playing.

Upvotes: 8

Related Questions