I am using socket.io
in an iOS React Native(v0.20) app
. The app tracks my location, and when my position changes it emits a message to a server. If the
I know there are hacks to get this done (i.e. the audio
hack), but there's a reason iOS doesn't allow long running tasks in the background - please rethink your design to allow a better product.
Using log running tasks will deplete the battery. If you need data updates, register to get push notifications using the Apple push service (it's free, if your doing it directly, or it was last time I dealt with a similar issue).
Location tracking, specifically, is an allowed background system service, consider using the native API for this.
As to pushing the data to the server, you won't be able to (and probably shouldn't) maintain a long lasting connection with the server.
Consider collecting data and uploading to the server the collected batch every once in a while - preferably when the app is reopened, so you don't waste resources in the background and get people upset about their battery life and their data consumption.