0

We are currently experiencing a very interesting issue when accessing the location in the background with CLLocationManager. The user has given our app the "whenInUse" permission for locations and in most cases the app provides location updates even when it's in the background. However, when we started to use other navigation apps in the foreground we saw that the func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) method was called with (kCLErrorDomain error 1.).

The user hasn't changed the location permission and we saw that locations were delivered once the user opened the app again. I don't see anything in the documentation explaining this issue, but I chatted with other developers that confirm that specific behaviour. Am I missing something?

JulianLenz
  • 188
  • 1
  • 6
  • Code 1 is "denied" hitch makes sense if you only have "when in use" permission. Have you requested background location updates (and therefore activated the blue location indicator when your app is in the background)? If you need reliable background updates for an extended period, you should request "always" permission. – Paulw11 Aug 21 '23 at 10:13
  • @Paulw11 Yes background location updates are enabled and I also see the inidicator in the background. I don't see anything in apples documentation regarding the need of an "always" permission when the app is in background. From my understanding "always" should be used when I want to received location updates when the app isn't running which is not my use case. – JulianLenz Aug 21 '23 at 12:41
  • No, always permission allows your app to continue to receive updates in the background without showing the blue location indicator and iOS will relaunch your app in some cases if it is jettisoned. If your app is actively using its "always" permission then it is less likely to be jettisoned by the operating system. The behaviour you describe sounds reasonable; you do not have always permission so continued background delivery of location is not guaranteed, particularly if other apps are needing memory – Paulw11 Aug 21 '23 at 20:54
  • @Paulw11 Thanks :) Can you guide me to the documentation that explains this? – JulianLenz Aug 22 '23 at 07:10
  • See "process location updates after an app launch" https://developer.apple.com/documentation/corelocation/handling_location_updates_in_the_background – Paulw11 Aug 22 '23 at 08:41

0 Answers0