Skip to content

@capacitor/geolocation sometimes not working #43

Description

@fg1998

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions