EddyVerbruggen / Insomnia-PhoneGap-Plugin

:sleepy: Prevent the screen of the mobile device from falling asleep

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

describe behaviour when calling allowSleepAgain without calling keepAwake in advance

prompteus opened this issue · comments

According to my experience (ios devices) allowSleepAgain causes app crash if keepAwake wasn't called in advance. I do not think this behaviour has to change, but I think it should be mentioned in Readme.

What's 'enableSleepAwake'?

And if you want to add something to the readme, please feel free to submit a PR.

My mistake, I've used bad method name here, so I updated the issue. I meant allowSleepAgain.

Yeah, I thought that order would be pretty obvious. But the plugin could perhaps harden against 'bad' usage patterns.

Which platforms do you see this crash on?

Feel free to submit a PR if you think a mention is required.

I use react - CRA + cordova. I have settings whether to keep the screen on, but the settings affects only one particular view, app should allow screen sleep elsewhere. So when the view enters the screen, it checks the settings and conditionally calls keepsAwake accordingly. When the view leaves the screen, it calls allowSleepAgain without checking whether keepAwake was called or not. I expected that nothing would happen if called "pointlessly", same as setting for example a flag on android pointlessly doesn't throw.

I will submit a PR when I get to it.

Exactly, that's what I meant with "the plugin could perhaps harden against 'bad' usage patterns". Happy to merge your PR!

Thanks. I've just requested it.

Perfect, that'll do for now.