hillasm
hillasm

Reputation: 103

iOS // CLLocationManager // didFailWithError is triggered with kCLErrorDenied while there are permissions

I have a navigation app that supports CarPlay connection. When running with CarPlay, some users report that they appear to not have GPS connection.

Looking at the logs I noticed that on app launch we're getting didFailWithError with error code kCLErrorDenied, so according to Apple's recommendation we stop updating location. This comes immediately after receiving locationManagerDidChangeAuthorization with kCLAuthorizationStatusAuthorizedWhenInUse with accuracy=0.

In this flow we also check CLLocationManager.locationServicesEnabled which returns true, CLLocationManager.authorizationStatus which returns kCLAuthorizationStatusAuthorizedWhenInUse and CLLocationManager.accuracyAuthorization which returns CLAccuracyAuthorizationFullAccuracy.

Users also confirm that they did give location permissions to the app and had location services enabled, also this issue was resolved after a few restarts of the app.

All the cases I encountered were on CarPlay using iOS 16.

Any idea why kCLErrorDenied could be triggered when there are location permissions?

Edit:

This issue appears to happen every time:

  1. Location permissions are set to "While Using"
  2. The app launches on CarPlay but not on the phone (there is no UIWindowScene instance).

Upvotes: 2

Views: 134

Answers (0)

Related Questions