最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Keep phone screen on with PWA (progressive web app) - Stack Overflow

programmeradmin2浏览0评论

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 ing back to the phone to turn it on? Another drawback to the screen sleeping is the javascript timer stops, ruining the workout timing.

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 ing back to the phone to turn it on? Another drawback to the screen sleeping is the javascript timer stops, ruining the workout timing.

Share Improve this question asked Jan 30, 2018 at 3:33 patmoodpatmood 1,5851 gold badge12 silver badges15 bronze badges 1
  • Possible duplicate of Can I prevent phone from sleep on a webpage – Venryx Commented Jul 29, 2019 at 2:32
Add a ment  | 

1 Answer 1

Reset to default 8

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

https://developer.mozilla/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 bee 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.

发布评论

评论列表(0)

  1. 暂无评论