Search code examples
javascriptobjective-cswiftreact-nativeobjective-c-swift-bridge

React-Native: Background app refresh while app closed


I need to update app's database every 30 or 60 minutes. After lots of search i've found this module :

https://github.com/transistorsoft/react-native-background-fetch

As it says in its page:

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).

What if i write some code in swift? I'm using sqlite in react native to store my data. if i write some code in swift which wakes up and check for new data, can i access the same database that i used to store my data in react native?

I'm using react-native-sqlite-storage to store my data in react native.

https://github.com/andpor/react-native-sqlite-storage


Solution

  • you can access the database you used to store in react native, if you run the background task under same app