简体   繁体   English

除了 react-native-background-task 之外,还有什么方法可以在 React Native 中执行后台任务吗?

[英]Is there any way to do background tasks in React Native other than react-native-background-task?

I'm trying to do in my React Native App that each X min the app fetch some data of my application included if the app is closed.我正在尝试在我的 React Native 应用程序中做,如果应用程序关闭,应用程序每 X 分钟获取我的应用程序的一些数据。 Or more similar, each X min I want to save a value in the AsyncStorage .或者更相似的是,每 X 分钟我都想在AsyncStorage中保存一个值。

It suppose that the react-native-background-task does that but, unfortunately, the project is abandoned with a lot of errors and bugs that make using it unviable.它假设react-native-background-task可以做到这一点,但不幸的是,该项目因大量错误和错误而被放弃,导致无法使用它。

Is there any other way to do it?还有其他方法吗?

For android, background service works fine which has its RN implementation in form of Headless JS task .对于 android,后台服务工作正常,其 RN 实现形式为Headless JS task For iOS, there is no such ready made library to be used in RN.对于 iOS,RN 中没有这样现成的库。 iOS being restrictive doesn't allows applications to take on the job queue control of OS straight away, though in native OS API, there are ways such things as per the business requirements. iOS 的限制不允许应用程序直接接管操作系统的作业队列控制,尽管在本机操作系统 API 中,有一些方法可以满足业务需求。

You can refer this to better understand which option to use for your use-case and can come up with a bridging module for RN as well.您可以参考这个以更好地了解您的用例使用哪个选项,也可以为 RN 提供一个桥接模块。

Have you tried react-native-queue .I think it will suit your requirement.您是否尝试过react-native-queue 。我认为它会满足您的要求。

Click here For complete guide . 单击此处获取完整指南

You can try react-native-background-job too.你也可以试试react-native-background-job

Click Here for Complete Guide单击此处获取完整指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM