在 React Native 中的特定时间执行代码 [英] Execute code at specific time in react native
问题描述
我想在特定时间执行我的 React Native 应用程序的某些功能,无论应用程序是打开的还是在后台.
I want to execute some function of my react native app at certain times, no matter if the app is opened or in background.
例如,在星期一下午 3:00 和星期三下午 5:00 执行函数
For example, execute the function at monday 3:00pm and wednesday 5:00pm
是否有可能实现这一目标?对不起,如果问题是菜鸟.另一种方法是从服务器端发送请求,但我想知道从应用程序端是否可行.
Is it possible to achieve this? Sorry if the question is noob. The alternative is to send a request from server side, but I want to know if is possible from the app side.
谢谢
推荐答案
目前完全不支持后台任务,仅针对 Android 部分还是有限制的:https://facebook.github.io/react-native/blog/2016/10/25/0-36-headless-js-the-keyboard-api-and-more.html
Currently there is totally no support for background tasks, only for Android bit it is still limited: https://facebook.github.io/react-native/blog/2016/10/25/0-36-headless-js-the-keyboard-api-and-more.html
React Native 也有限制,当应用在后台时,js 网桥停止接收消息.
There is also limitation in React Native, when the app is in the background the js bridge stops getting messages.
这篇关于在 React Native 中的特定时间执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!