Android – framework for repeatedly executing background tasks

I'm using ionic framework / Cordova to build my application. I installed this plug-in Cordova plugin background mode to work in background mode

Q: but now how can I complete the task of repeating every 30 minutes in the background?

Do you know another plug-in?

thank you

resolvent:

Depending on the repository you use, the code must look like this:

@H_404_17@// Run when the device is ready
document.addEventListener('deviceready', function () {

    // Android customization
    // To indicate that the app is executing tasks in background and being paused would disrupt the user.
    // The plug-in has to create a notification while in background - like a download progress bar.
    cordova.plugins.backgroundMode.setDefaults({ 
        title:  'TheTitleOfYourProcess',
        text:   'Executing background tasks.'
    });

    // Enable background mode
    cordova.plugins.backgroundMode.enable();

    // Called when background mode has been activated
    cordova.plugins.backgroundMode.onactivate = function () {

        // Set an interval of 30 minutes (1800000 milliseconds)
        setInterval(function () {

            // The code that you want to run repeatedly

        }, 1800000);
    }
}, false);

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>