EddyVerbruggen / Insomnia-PhoneGap-Plugin

:sleepy: Prevent the screen of the mobile device from falling asleep
265 stars 105 forks source link

Can't make it work #46

Open Danpelle opened 6 years ago

Danpelle commented 6 years ago

I'm developing an app using Cordova, and the Insomnia plugin is perfect for what I need. But I can't make it work. To make everything as simple as possible, I created a new Cordova project, installed the plugin automatically (using the CLI) and add the following lines in the original Cordova index.html file to call the KeepAwake command:

`

` I have tried to call the Insomnia plugin into the device-ready call function, but it also didn't work. Here is the code: `` The phone still auto-lock after 30s. I'm using an iPhone 5s running iOS 10.3.3 and Cordova iOS version 4.4.0. What's wrong??? Thank you very much!
zjbennett commented 6 years ago

I'm having the exact same issue as above.

zjbennett commented 6 years ago

Just to let you know I tried everything but could on get this working on a button. I did however get it working using the onLoad Function in the <body> tags. Give that a go.

<body onLoad="window.plugins.insomnia.keepAwake()">

sharpMouse commented 5 years ago

Has same problem. But body and button tags don't work too ((((.

Using: iPhone 5s, iOS 12.2, PhoneGap ios engine 4.5.5, Insomnia 4.3.0 via PhoneGap build.

@zjbennett: Can you provide more info? May be full html file?

marcosliell commented 4 years ago

I also need the plugin to load when the app is opened, not who clicks the button. Any solution?

marcosliell commented 4 years ago

I win!

This code works for me.