我需要每 30 或 60 分钟更新一次应用程序的数据库。经过大量搜索,我找到了这个模块:
https://github.com/transistorsoft/react-native-background-fetch
正如其页面中所说:
iOS Background Fetch is basically an API which wakes up your app about every 15 minutes (during the user's prime-time hours) and provides your app exactly 30s of background running-time. This plugin will execute your provided callbackFn whenever a background-fetch event occurs. There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible value of UIApplicationBackgroundFetchIntervalMinimum -- iOS determines the rate automatically based upon device usage and time-of-day (ie: fetch-rate is about ~15min during prime-time hours; less frequently when the user is presumed to be sleeping, at 3am for example).
如果我用 swift 写一些代码会怎样?我在 react native 中使用 sqlite 来存储我的数据。如果我在 swift 中编写一些代码来唤醒并检查新数据,我可以访问我用来在 React Native 中存储数据的同一个数据库吗?
我正在使用 react-native-sqlite-storage 将我的数据存储在 react native 中。
最佳答案
如果你在同一个应用程序下运行后台任务,你可以访问你用来存储在 react native 中的数据库
关于javascript - React-Native:应用程序关闭时后台应用程序刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40068893/