Unable to get locations when app is killed/suspended even if background modes with Location Updates and Background fetch are enabled. My use case was to get device location irrespective of App State for every 10 Mins.
There is no mechanism that will give you a location update every 10 minutes (or any such arbitrary period) irrespective of app or device state.
You can either use the low power monitoring APIs like CLMonitor, Region Monitoring, Visits, or Significant Location updates - which will send location updates to your app even after it has been killed - but requires the device to move a certain amount or to certain locations depending on the specifics.
Your other option is to use the high power APIs like liveUpdates()
or startUpdatingLocation()
. These will give you continuous location updates with some nuances.
startUpdatingLocation()
will give you updates every second whether the device is moving or not. But if the app is terminated you cannot continue receiving updates until the user launches the app to start location updates again.
CLLocationUpdate.liveUpdates()
will restart location updates after the app is terminated, but also only send updates if the device is moving.
So, you have a number of options here, and you can choose the API that is most suitable for your use case. Also keep in mind that liveUpdates()
and startUpdatingLocation()
require a lot of power and may be considered overkill if you only need an approximate location every 10 minutes.
Argun Tekant / DTS Engineer / Core Technologies