ionic-team / ionic-team/capacitor-geolocation
bug: when called subsequently, Geolocation.getCurrentPosition() doesn't resolve
- Dominant language
- Swift
- Stars
- 12
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
# Bug Report
## Capacitor Version
`npx cap doctor` output:
```bash
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 2.1.2
@capacitor/core: 2.1.2
@capacitor/android: 2.1.2
@capacitor/electron: 2.1.2
@capacitor/ios: 2.1.2
Installed Dependencies:
@capacitor/ios not installed
@capacitor/electron not installed
@capacitor/cli 2.1.2
@capacitor/android 2.1.2
@capacitor/core 2.1.2
[success] Android looking great! 👌
```
## Affected Platform(s)
- [x] Android
- [ ] iOS
- [ ] Electron
- [ ] Web
## Current Behavior
If multiple parallel calls to `Geolocation.getCurrentPosition()` are made, only last one returns any result, success or error.

## Expected Behavior
Every call to `Geolocation.getCurrentPosition()` should have it's promise fullfilled or rejected.
This shoud be the way, besides what the plugin does internally (which native API uses, cached position, ...)
## Sample Code or Sample Application Repo
```js
const params = {
enableHighAccuracy: true,
maximumAge: 20000,
timeout: 50,
};
console.log('position 1 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
position => console.log('position 1', position),
error => console.error('position 1 error', error)
);
console.log('position 2 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
position => console.log('position 2', position),
error => console.error('position 2 error', error)
);
console.log('position 3 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
position => console.log('position 3', position),
error => console.error('position 3 error', error)
);
console.log('position 4 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
position => console.log('position 4', position),
error => console.error('position 4 error', error)
);
```
## Reproduction Steps
* Create a new test project based on capacitor starter `npx @capacitor/cli create`
* Add the example code below to any JS file/script (I put it in `js/capacitor-welcome.js` file)
## Other Technical Details
`npm --version` output: `6.14.4`
`node --version` output: `v12.17.0`
Contributor guide
Assessment
This issue has not been assessed yet.