I want to send updates to a database from the background every now and then with an app that I am building (for HealthKit things like user's steps taken, heart rate, etc.). I believe I can do this using background fetch. However, from everything I have read on background fetch, it seems like it is mainly just used to grab data for the app so it can display correctly when the user opens it next. Is it reasonable (or recommended) to use background fetch to send data to a database? Thanks.
Asked
Active
Viewed 392 times
1
-
You could use it for upload/download. Without knowing rest, it is hard to give recommendation. Periodically syncing data to server, so user don't loose data sounds good idea to me. – k-thorat May 02 '19 at 04:51
1 Answers
0
Depends on what you want to send. Location services for example have their own background capability with events that you should listen on. In their delegate methods you can send that data to your API.
Background fetch is as the name says rather used for randomly receiving custom data while the app is in background. There is no fixed schedule when the callback gets called. So you might actually either send the same data many times because they did not get updated, or not enough times that you miss some updates (unless you keep them in a database locally)

MartinM
- 832
- 6
- 12
-
I am using it for healthkit data (steps taken, floors elevated, heart rate, etc.) – Slaknation May 02 '19 at 13:35