EddyVerbruggen / Insomnia-PhoneGap-Plugin

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

Struggling to get it to work in Android 4.4.2 #13

Closed ojsglobal closed 9 years ago

ojsglobal commented 9 years ago

Hey

This seems to be the answer to my prayers, but I just can't get it to work!

I'm using the latest version of both your plugin and Phonegap Build, but it seems to fail where ever I call it from:

config.xls

index.js var app = {

    initialize: function() 
    {

        this.bindEvents();

    },

bindEvents: function() { document.addEventListener('deviceready', this.stayAwake, false); },

    stayAwake: function()
    {
        var worked = function()
        {
            $('#message').append('AWAKE');

        }

        var failed = function()
        {
            $('#message').append('BROKE');

        }

        window.plugins.insomnia.keepAwake(worked, failed);
    }

}

Just keep getting the broke message and the screen goes off.

Any ideas?

EddyVerbruggen commented 9 years ago

Hi, sorry I couldn't answer any quicker.

Your code is a bit broken up, but I think the problem is in this.stayAwake. Can you try making stayAwake a global function and not prefix it with this?

Best, Eddy