Dear community,
I am waiting online for some urgent help.
I’ve added: Privacy - Location When In Use Usage Description to xcode plist.
When I call navigator.geolocation.getCurrentPosition , a permission dialog pops up and ask for permission, before I hit “Allow”,
An error gets returned already:{“code”:1,“message”:“Location services are disabled.”}
Code 1 actually means permission denied, correct?
Under time pressure, any help would be greatly appreciated.
How to solve it?
thanks
- Check your GPS is on
- Check permissions in manifest file
app/res/xml/config.xml
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker" />
app/AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
If still not solved then take a look in this article -:
Geolocation Permissions
HI anuijsinghwd,
thx for the quick help.
The config you just gave is old already. I have issues with only iOS.
My issue is I do get the permission dialog, but the code runs anyway without waiting user to hit “allow”.
thx anujsinghwd.
but the solution on that thread is to use cordova-pligin-geolocation but my issue is related to this plugin. I just can’t find a way to pause the code before user interact with the permission dialog.
This issue only happens on iOS
To answer my own question.
I ended up using https://github.com/dpa99c/cordova-diagnostic-plugin to check the permission status. Pops up a Popup with a button. When user dismisses the permission dialog, he has to dismiss the popup by clicking on the button. Then I check the permission status again. It’s not a solution, it’s just a workaround. A bit ugly but works.