NoSleep.js icon indicating copy to clipboard operation
NoSleep.js copied to clipboard

not working with apple-mobile-web-app-capable

Open Diego020 opened this issue 7 years ago • 3 comments

it was not working for the web app i'm designing, so in an attempt to problem solve I cloned the example site, and added : <meta name="apple-mobile-web-app-capable" content="yes">

I opened the site on device with ios 9, saved it to home screen, opened it, clicked the button, and device went to sleep after standard time. (same behaviour on android)

Diego020 avatar Jan 05 '18 17:01 Diego020

@richtr Do you have any idea whether or not this is fixable?

arggh avatar Jan 02 '19 07:01 arggh

I was able to get NoSleep working when launched from the home screen - at least it works on iOS 12.

henrydawson avatar Jan 25 '19 03:01 henrydawson

I am having the same issue. It ONLY works right after I added the app to the homescreen, but it doesn’t if I close and open it again.

Edit: It’s getting more interesting, I actually have that same problem if I do not add it to my homescreen, if I re-open iOS safari (without doing a hard reload) it doesn’t work anymore... I have the idea the dummy video is “stuck” or not able to play anymore.

Edit2: did some more investigating, it seems it’s actually working always if I reconstruct nosleep before enabling it every time, so like

let nosleep = null;

function enable() {
  if (nosleep) nosleep.disable(); // Just to be sure if you forgot to disable.
  nosleep = new NoSleep();
  nosleep.enable();
}

function disable() {
  nosleep.disable();
}

It seems to fix the problems I had, but I’m just giving the information I now have, I’m not sure if it’s the actual solution.

ngerritsen avatar May 17 '19 16:05 ngerritsen