10

We're currently developing an HTML 5 app for the iPad and looking for a method to prevent the screen from going to standby/sleep. I understand this is possible with a native iOS app but what about an HTML5-based web application?

Thank you for any suggestions and answers.

crockpotveggies
  • 12,682
  • 12
  • 70
  • 140
  • 1
    I've posted some findings on one way to do this here: http://stackoverflow.com/questions/9709891/prevent-ios-mobile-safari-from-going-idle-auto-locking-sleeping – forrex Mar 16 '12 at 05:18
  • 2
    You can do this using an HTML5 audio element, in a playback loop: http://stackoverflow.com/a/15210029/1539698 – Bill Strathearn May 01 '13 at 15:27
  • 1
    I managed to prevent sleep in my Webapp: http://stackoverflow.com/a/17912979/784318 – Besi Jul 28 '13 at 21:19
  • I am OK with my iPhone going to lockscreen but would like for the audio controls to continue working and for my HTML/JavaScript web app to continue feeding the audio player new tracks. This seems to have broken in iOS 8? – pbreitenbach Nov 12 '14 at 22:10

3 Answers3

11

Nope, you can't do this with a plain website/web app.

One option could be to create a native app containing simply a UIWebView. The native app would contain code to load your web app into the webview and disable the idle timer. (It's the idle timer that puts the iPad to sleep.)

wpearse
  • 2,422
  • 2
  • 29
  • 30
  • Seems like a logical workaround. Does the UIWebView use the same rendering engine as Safari and support the same HTML5 standards? – crockpotveggies Sep 19 '11 at 21:50
  • It supports the same HTML5 standards, but IIRC it uses a different rendering engine: Mobile Safari can render a webpage partially/incrementall, a UIWebView can't. This makes a UIWebView appear slower when loading a webpage. – wpearse Sep 19 '11 at 22:06
  • I think this will require some testing but it's certainly an option. I'll accept the answer and post back any relevant findings. thanks! – crockpotveggies Sep 19 '11 at 22:35
  • And then you'll be at risk of not being accepted on the app store ... http://stackoverflow.com/questions/5478848/does-apple-reject-mobile-web-shell-applications – oromoiluig Sep 16 '16 at 09:55
2

Adjusted settings to not let the iPad lock the screen. Fired up a page that uses websockets. In an simple interval I used the socket to send and recieve a message every 60s. Worked for a couple of hours, then I closed it.

I also tried to switch tabs. Worked.

slang
  • 626
  • 7
  • 26
Daniel
  • 8,133
  • 5
  • 36
  • 51
0

Standby/sleep modes are rooted to the OS, so it's pretty much impossible to achieve with HTML5. Why would you do this anyway? Maybe you could think of a timeout function in case the device was in standby/sleep and came back. This answer looks useful but I haven't yet test it.

Community
  • 1
  • 1
DZenBot
  • 4,806
  • 2
  • 25
  • 27