Hi, I am working on a React Native app and i want to have a latitude longitude of a user in every 15 minutes and want to do something like an api call with it. I want to keep continuing this no matter my app is in background, foreground or in killed state. Is there any way or method through which i can achieve this natively or using React Native?
Background Task in iOS App
There is no API or facility to get a users location every 15 (or any other time period) minutes.
The new CoreLocation API liveUpdates(_:) as shown in the sample project Adopting live updates in Core Location will give you frequent updates and will work whether your app is in the foreground, background or killed state. Then you can ignore any updates in between the 15 minutes you need to make your API call to update your server with it.
You will still not be able to ask for an update if the device has stopped moving. Then your server would need to assume that if there are no updates, then it is likely that the device has not been moving, or something went wrong with your app communicating with the server, which is something you will need to manage.
Or, you can use the old API startUpdatingLocation() which will continue to send updates even if the device is standing still, but the updates will stop if the app is terminated.
You would need to decide which situation is more important to you and use the API most appropriate to your use case.
Argun Tekant / DTS Engineer / Core Technologies