每隔30秒后安排后台任务 - react-native。

问题描述 投票:0回答:1

我想使用react-native来安排每30秒后运行的后台任务。

我见过以下图书馆

  1. react-native-background-job
  2. react-native-background-task
  3. react-native-background-fetch

但他们都有一个限制,即我不能设置运行作业的频率小于15分钟。

我也检查过 react-native-background-timer 但当应用程序终止时,它似乎并不工作。

如何实现每30秒后就可以安排后台任务?

react-native background-task
1个回答
0
投票

你可以使用 react-native-background-job npm 来实现。

https:/github.comvikerireact-native-background-jobblobmasterexampleindex.js。

参考该代码为例。

你还需要在你的androidManifest.xml(androidappsrcmain)中添加前景权限。

< uses-permission android:name ="android.permission.WRITE_EXTERNAL_STORAGE" >

在"< "application"> "标签上方添加该行。

© www.soinside.com 2019 - 2024. All rights reserved.