Thanks to visit codestin.com
Credit goes to github.com

Skip to content

nosleep.enable() not working on bookmark saved as an application in iphone #161

@tazo-taz

Description

@tazo-taz
  • 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();
    };
  }, []);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions