EddyVerbruggen / Insomnia-PhoneGap-Plugin

:sleepy: Prevent the screen of the mobile device from falling asleep
264 stars 106 forks source link

Using camera in my app lets the app sleep. #29

Closed RedTint closed 8 years ago

RedTint commented 8 years ago

Hi Team,

I'm not sure whether you guys also encountered this but using camera on my phone (inside the app) to upload an image freshly taken from cam makes the app sleep even when .keepAwake() is called.

Thanks!

EddyVerbruggen commented 8 years ago

Hey, the team here :)

I'm guessing the Android activity gets recreated after the camera was used. Interesting find.

RedTint commented 8 years ago

Hi there,

This is actually from ios.

EddyVerbruggen commented 8 years ago

Ah, ok - this SO issue describes the problem perfectly; the Camera is likely kept awake by iOS and it sets your app to 'allowed to sleep' afterwards. This should be handled better by Apple, but it is what it is.

Since I can't (and won't) hijack the camera picker delegate and re-apply Insomnia you should manually do this in your app: once the camera callback gives control back to your app invoke the plugin again.

Thanks for reposting this quirk! I'm updating the README accordingly.

RedTint commented 8 years ago

You're welcome. And thanks for solidifying my theory of what could be happening. :)