ionic-team / ionic-team/capacitor-geolocation

@capacitor/geolocation sometimes not working

Open
#43 8 comments 5 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
12
Forks
19
PR merge metrics
No merged PRs in 30d

Description

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.