首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重复背景任务离子框架

重复背景任务离子框架
EN

Stack Overflow用户
提问于 2015-08-18 10:06:16
回答 2查看 8.1K关注 0票数 4

我正在使用ionic-framework / cordova来构建我的应用程序。我已经安装了这个插件科多瓦-插件-背景模式在后台模式下工作。

Q:,但是现在我怎么才能在后台每30分钟重复一次任务呢?

你知道另一个插件吗?

谢谢

EN

回答 2

Stack Overflow用户

发布于 2015-12-14 13:03:43

根据您使用的存储库,代码必须如下所示:

代码语言:javascript
复制
// 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);
票数 8
EN

Stack Overflow用户

发布于 2015-09-14 19:36:17

您可以在一段时间内使用$timeout$interval来完成此任务。

间隔期角钢

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32069388

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档