3 Replies Latest reply on Aug 11, 2016 12:38 PM by kerrishotts

    Phonegap background plugin not calling function


      I have been searching all over the web for a solution for my problem, but the only thing i found, is people with the same issue that i have. I am using this plugin which supposedly has the ability to keep running functions when the app is in background mode, what i want is for a simple ajax function to be called every 1 minute even in background. The implementation seems to be very simple, but there is a function that it is not working, this is my code:


      onDeviceReady: function()
        console.log('onDeviceReady start');

        // Prevent the app from going to sleep in background
        cordova.plugins.backgroundMode.setDefaults({ text:'Em background.'});
        // Enable background mode

        // Called when background mode has been activated
        cordova.plugins.backgroundMode.onactivate = function ()
        this function does not work, a simple console.log doesn´t do anything.


      I´m using weinre to see what happens after compile my code in phonegap build, the only thing that i can control is the cordova.plugins.backgroundMode.setDefaults({ text:'Em background.'}); function. I enter the app, and then hit the home button, and there´s a little notification on the top that says "the app is in background", then my setDefaults text appears and that´s it!!. I have seen a lot of people with the same problem in that exact same function.

      Does anyone came across this problem? any help would be appreciated.