Open aprat84 opened 4 years ago
Having the same issue
Same here. No news on this?
Edit: A workaround could be a helper method, that returns a custom observable, that is resolved for all subscribers, when 'Plugins.Geolocation.getCurrentPosition' returns a value:
private _getCurrentPosition$: Subject<LatLng>;
...
getCurrentPosition() {
if (!this._getCurrentPosition$) {
this._getCurrentPosition$ = new Subject();
Plugins.Geolocation.getCurrentPosition().then((currentPosition) => {
this._getCurrentPosition$.next(currentPosition);
this._getCurrentPosition$.complete();
this._getCurrentPosition$ = null;
});
}
return this._getCurrentPosition$;
}
I've noticed getCurrentPosition doesn't resolve at all if watchPosition()
has been called before, not sure if related
Bug Report
Capacitor Version
npx cap doctor
output:Affected Platform(s)
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
Reproduction Steps
npx @capacitor/cli create
js/capacitor-welcome.js
file)Other Technical Details
npm --version
output:6.14.4
node --version
output:v12.17.0