capacitor-plugins
capacitor-plugins copied to clipboard
@capacitor/geolocation sometimes not working
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