iOS 18 - Capacitor 7 - Geolocation.watchPosition

I am having a hard time figuring out what is wrong with Geolocation.watchPosition on iOS. Already some time ago I noticed that iOS seems to be a bit phlegmatic when it comes to start watching the user’s location, i. e. it often took some 10 to 30 (sometimes evne 60?) seconds until the location started being tracked, but once it started it would work reliably.

However, somewhere with the update from @capacitor/geolocation from v7.0.0 to v7.1.1 things got significantly worse, to the point where I can see in Xcode that location services are active and running (and I can see the blue, respectively black location icon on the left of the iPhone notch, indicating that location services are active), but the location in my app isn’t updated (mind you: it did update before). This happens on an iPhone 16 Pro with iOS 18.


The logs would show To Native -> Geolocation watchPosition 106439503 but no ongoing incoming position data with timestamp, lat, lng, etc., coming in as they did before.

Sometimes, but only sometimes, closing the app (putting it in background mode) and re-opening it, would result in retrieval of 1 (one) location object, and then again silecne tumbleweed, nothingness, the void…

Funnily enough on an iPhone XS with iOS 17 it eventually will start to track location, but it is unpredictable as to when (at least I can’t see any correlation to anything that would trigger it).

Before you ask: yes, I have allowed location services, and yes, I have filled out NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationUsageDescription (deprecated? maybe, but for good measure - pun intended!), and NSLocationWhenInUseUsageDescription in my Info.plist.

Debug info only sometimes would show the error code OS-PLUG-GLOC-0002 which does tell me that according to the docs “There was en error trying to obtain the location.”, however, I already knew that.

Android Studio on the other hand does show (as it did before) the logs for location requests:

I would really appreciate any hints, pointers, tips and help shedding light on this issue, because I am currently on a loss as what to do next :grimacing:

I am using:

  • "@ionic/core": "8.5.3"
  • "@ionic/vue": "8.5.3"
  • "@capacitor/android": "7.2.0"
  • "@capacitor/ios": "7.2.0"
  • "@capacitor/geolocation": "7.1.1"

Ok, nevermind, kind of…

It turns out that this must be some bug in iOS (18). Once I put the setting “Allow access to Location” to “Always” it started working again. And it’s working since, regardless on which setting, being it “Ask next time”, “When in use” or “Always”.

Thanks Apple™ for wasting 2 (in words: two!) days of my life :face_vomiting:

2 Likes