Closed ASHBAW closed 1 year ago
Experiencing a similar issue where it never returns anything. We have no idea in which situations, but it let to deploying a version where users cannot interact with our app any longer.
Same problem. Plugin doesn't work on fresh ionic 6 installation out of the box. Module doesn't produce errors and doesn't give result. Tested on emulator.
I found it out. I set it to enableHighAccuracy:true and it found coordinates Geolocation.getCurrentPosition({enableHighAccuracy:true});
I also have enableHighAccuracy:true and am able to obtain coordinates when GPS is available.
My issue is when GPS is enabled on a device but is not able to obtain location (say you are in a place where you cannot get the location even though the device has GPS enabled). I get no feedback/error indicating it was not able to obtain the location.
As stated in my first post I tried .catch and try/catch.
Do you have a way to catch an error in the event it is not able to obtain the location coordinates?
For the time being I switched to another plugin. It catches error conditions. If this gets resolved I will try this plugin again.
For the time being I switched to another plugin. It catches error conditions. If this gets resolved I will try this plugin again.
Which plugin? I’m facing same issue and looking to switch.
Same problem here but when I restart my application and requesting the geolocation again, the whole app crashes. Is this happening for you also?
I have an ionic 6 angular application using all capacitor plugins except for this one. For geolocation I am using this cordova plugin: https://www.npmjs.com/package/cordova-plugin-geolocation
npm i cordova-plugin-geolocation
npx cap sync
Here is some more information on using capacitor and cordova: https://capacitorjs.com/docs/v2/cordova/using-cordova-plugins
Any update on this?
I am guessing the PositionOptions timeout (default 10000 milliseconds) is not working properly.
Any idea how we can check that?
I have similar issue on a emulated device without a gps sensor (tablets/ TVs/ wearables).
My workaround is to reject promise manually after timeout, as in this Stack Overflow answer
In @capacitor/geolocation: ^4.0.0 , Geolocation.checkPermissions() throws the wanted error when no location service available. Small timesaving tip, it literally throws an error instead of returning a rejected promise.
In version 4.0.0 of the plugin the logic of getCurrentPosition()
has changed internally, give it a try.
I can't reproduce, so I'm closing the issue.
If somebody is still having issues with version 4.0.0 or newer, create a new issue providing a sample app and more information about the devices where the plugin is not resolving/rejecting.
I am not sure how to detect an error - no location service available (i.e. GPS may be enabled but the device is not able to get the location)?
I have tried wrapping
const coordinates = await Geolocation.getCurrentPosition();
in a try/catch block.
I have also tried the following:
by default the timeout is 10000 ms but I am not able to detect an error.
I might be missing something from the documentation that describes this?
When GPS is able to get the location everything works great.
Thanks for any insight.