Closed dominikse closed 8 months ago
You are missing the required usage description
<key>NSLocationWhenInUseUsageDescription</key>
<string>I want to know where the user is</string>
In older iOS versions Xcode would tell you or even would make your app crash, but it looks like on iOS 17 it no longer tells you the usage descriptions are missing, so maybe the plugin should reject if no usage description is present.
You are right, thanks a lot! Great! This resolved the issue. I've had only supplied "NSLocationAlwaysAndWhenInUseUsageDescription" assuming this will cover all the usage descriptions.
@capacitor/geolocation
doesn't work in the background, so you only need NSLocationWhenInUseUsageDescription
.
NSLocationAlwaysUsageDescription
is in the docs I linked, but it's deprecated and we have removed it in the Capacitor 6 docs and documenting it needs to be removed. That's why I only mentioned NSLocationWhenInUseUsageDescription
.
So you don't need NSLocationAlwaysAndWhenInUseUsageDescription
but NSLocationWhenInUseUsageDescription
, unless you have another geolocation plugin that works in background.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.
Bug Report
Plugin(s)
capacitor/geolocation@5.0.7
Capacitor Version
Platform(s)
iOS
Current Behavior
Ionic blank starter app with only geolocation plugin for test purposes.
In web (Google Chrome via "ionic serve") it prompts for location permissions and if granted it resolves the location. Works like expected in web.
With iOS it isn't working at all and this statement "let coord = await Geolocation.getCurrentPosition();" is not resolving maybe because permissions are not being prompted? Also no error is being thrown/catched.
Even if trying to re-prompt the permissions manually by calling "Geolocation.requestPermissions();" nothing shows up and getCurrentPosition is not resolving at all, so no result.
Not working in iOS Simulators (17.2) and also not on actual iOS devices (17.2.1).
Expected Behavior
Coordinates should be returned/resolved like in web environment (Google Chrome).
Code Reproduction
https://github.com/dominikse/ionic-cap-geotest
Other Technical Details
iOS platform details (cap sync):