Insomnia-PhoneGap-Plugin icon indicating copy to clipboard operation
Insomnia-PhoneGap-Plugin copied to clipboard

Can't make it work

Open Danpelle opened this issue 7 years ago • 5 comments

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:

`

// Cordova is loaded and it is now safe to make calls Cordova methods
//

function onDeviceReady() { window.plugins.insomnia.keepAwake() `

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!

Danpelle avatar Nov 27 '17 18:11 Danpelle

I'm having the exact same issue as above.

zjbennett avatar Jan 09 '18 15:01 zjbennett

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()">

zjbennett avatar Jan 11 '18 13:01 zjbennett

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?

sharpMouse avatar Apr 17 '19 20:04 sharpMouse

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

marcosliell avatar Sep 18 '19 12:09 marcosliell

I win!

This code works for me.

marcosliell avatar Sep 23 '19 11:09 marcosliell