Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Wakelock does not avoid dimming screen #172

Closed
danielefolatelli opened this issue Apr 15, 2022 · 4 comments
Closed

iOS Wakelock does not avoid dimming screen #172

danielefolatelli opened this issue Apr 15, 2022 · 4 comments
Labels
requires further investigation The root cause of the issue has not yet been fully identified

Comments

@danielefolatelli
Copy link

Hi, mi app is a game where players have to think for a while. So sometimes they are meditating and not interacting at all. I only have timers running at the time. I added the wakelock.enabled command after installing the plugin but I see that the screen dims and then closes according to the time set in the AutoLock field in Display and Brightness for the iOS device.
Is it not the plugins mission to avoid the screen from dimming?

@creativecreatorormaybenot
Copy link
Owner

Hi @danielefolatelli - thanks for using the plugin. Did you follow the advice from the README? (https://github.com/creativecreatorormaybenot/wakelock/blob/main/wakelock/README.md#calling-wakelockenable-in-main)

Calling Wakelock.enable() in main()

As touched on in the previous paragraph, calling Wakelock.enable() in your main() function is
not the best approach for a number of reasons.

The most important factors are:

  1. Users expect their screen to automatically turn off unless e.g. a video is playing.
    It is unlikely that your whole app requires the screen to always stay on.
  2. The wakelock can be released by external sources at any time (e.g. by the OS).
    Only calling Wakelock.enable() once will most likely mean that the screen turns off at one
    point or another anyway.

This is why you should instead prefer to enable the wakelock whenever components inside of your app
that require the screen to stay on are active. This can e.g. happen in the build method of your
widget.

@danielefolatelli
Copy link
Author

danielefolatelli commented Apr 17, 2022 via email

@creativecreatorormaybenot
Copy link
Owner

@danielefolatelli Can you call await Wakelock.enabled at the time the screen starts to dim?

@creativecreatorormaybenot creativecreatorormaybenot added the requires further investigation The root cause of the issue has not yet been fully identified label Apr 17, 2022
@creativecreatorormaybenot
Copy link
Owner

I will soon discontinue this repository. Please use wakelock_plus: ^1.1.6 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires further investigation The root cause of the issue has not yet been fully identified
Projects
None yet
Development

No branches or pull requests

2 participants