- Device Name: iPhone
- Device Version: 11
- Browser Name: Safari
- Browser Version: latest
- NoSleep.js Version: ^0.12.0
Expected Behavior
The noSleep.enable() function should prevent the screen from sleeping when the web application is launched from a bookmark saved as an application on an iPhone.
Actual Behavior
The noSleep.enable() function does not prevent the screen from sleeping when the web application is launched from a bookmark.
Code
useEffect(() => {
const noSleep = new NoSleep();
const documentOnClick = async () => {
try {
const a = await noSleep.enable();
console.debug("no sleep enabled", a);
} catch (e) {
console.debug("no sleep prevented");
}
};
document.addEventListener("click", documentOnClick);
return () => {
document.removeEventListener("click", documentOnClick);
noSleep.disable();
};
}, []);