Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@capacitor/geolocation sometimes not working #2165

Open
fg1998 opened this issue Aug 7, 2024 · 4 comments
Open

@capacitor/geolocation sometimes not working #2165

fg1998 opened this issue Aug 7, 2024 · 4 comments

Comments

@fg1998
Copy link

fg1998 commented Aug 7, 2024

Bug Report

Plugin(s)

@capacitor/geolocation

Capacitor Version

@capacitor/ios: not installed
@capacitor/cli: 6.1.1
@capacitor/core: 6.1.0
@capacitor/android: 6.1.0

VM3:339 result Geolocation.getCurrentPosition (#95975845)
VM3:347 {message: 'location unavailable'}

Platform(s)

ANDROID

Current Behavior

Sometimes Geolocation.getCurrentPosition() simples does not provide any coordinates, just return LOCATION UNAVAILABLE. This issue occurs sometimes after install app, or after live run. But not all times.
When this issue occurs, I just open Google Maps and the dot with my current position is GRAY. After 1 or 2 seconds, it became blue and than the error on capacitor does not occur anymore

Code Reproduction

async getCoordenadas() {
try {
const resp = await Geolocation.getCurrentPosition();

  return {
    error: false,
    latitude: resp.coords.latitude,
    longitude: resp.coords.longitude,
    msg: '',
  };
} catch (err: any) {
  return {
    error: true,
    msg: `GetCoordenadas: ` + err.message,
    latitude: 0,
    longitude: 0,
  };
}

}

Other Technical Details

Galaxy A54, Galaxy S9, Galaxy S10 Lite

@Ionitron
Copy link
Collaborator

This issue needs more information before it can be addressed.
In particular, the reporter needs to provide a minimal sample app that demonstrates the issue.
If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks!
Ionitron 💙

@fg1998
Copy link
Author

fg1998 commented Aug 27, 2024

Ok, there is it

https://github.com/fg1998/geolocation-bug

The error occurs occasionally. But the screenshots prove the error.

Running on physical device Samsung Galaxy a54 and Samsung Galaxy S10 lite

@Gollm
Copy link

Gollm commented Sep 3, 2024

I can confirm that users report the same behavior. (Since Capacitor version 6, but it does not necessarily have to be due to the version. The Android hardware or software may also have something to do with it) and I have also seen the error message before.

But as already written: Quite sporadic and cannot be firmly defined.

@emnljs
Copy link

emnljs commented Sep 20, 2024

Yes I can confirm also I'm using physical devices that shows the "location unavailable" error. I did @fg1998's technique of "restarting" the location by opening Google Maps and it works again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants