creativecreatorormaybenot/wakelock

iOS Wakelock does not avoid dimming screen

danielefolatelli opened this issue · 4 comments

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?

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 Can you call await Wakelock.enabled at the time the screen starts to dim?

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