Location Updates when App is killed/Suspended

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.

Answered by Engineer in 795832022

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

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

Thanks For the Inputs.

CLLocationUpdate.liveUpdates() - I cannot use this since we have customers from iOS 15.0 where liveUpdates() is available from iOS 17.0+

CLMonitor - Same with this. CLMonitor is also from iOS 17.0+

Region Monitoring - We cannot use the geoFencing with our implementation due to logical limitations

Significant Location updates - This gave some locations but not continuous. Comparing the locations with the app in background/Foreground, Many of the locations were not reported.

Regarding CLVisit I will update here. I need to implement and see if it helps

FYI -

Location Updates when App is killed/Suspended
 
 
Q