即使设备关闭也执行 Cron 任务

时间:2021-02-06 09:54:17

标签: flutter dart cron

我有这个应该每天执行一次的 Cron 函数。这是:

   scheduleWipe() {
  try {
    var cron = new Cron();
    cron.schedule(Schedule.parse('* 10 * * *'), () async {
      resetFunction();
    });
  } catch (e) {
    print(e);
  }
}

然后我在 main.dart 中初始化它:

void main() async {

  scheduleWipe();

  runApp(MyApp());
}

它可以工作,但事实是,它仅在设备打开时才执行。有没有办法即使设备没有打开也必须运行,即只要设备打开就执行任务?

0 个答案:

没有答案
相关问题