newtonstudio commented on issue #255:
URL:
https://github.com/apache/cordova-plugin-geolocation/issues/255#issuecomment-1331603398
Hi Guys, I'm also suffering from this issue since few weeks ago.
After doing some research, i try to combine several methods by solving this
issue. In summary:
1. Go to google play and update user mobile to latest android web view
version.
2. Install LocationProvider cordova plugin (use ts-ignore to prevent ionic
build error)
3. enable timeout option on geolocation, and try use LocationProvider if
geolocation has failed.
It works for me. Hope it helps.
My Environment is Angular+Ionic 4 with Cordova.
I tried to install two of this plugin:
cordova-plugin-geolocation 4.1.0 "Geolocation"
cordova-plugin-location-provider 1.5.4 "LocationProvider"
in my ts file:
```
import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation';
import { Platform } from '@ionic/angular';
```
```
//dependency injection
constructor(private geolocation: Geolocation, private platform: Platform){}
```
```
somefunction(){
this.geolocation.getCurrentPosition({ maximumAge: 3000, timeout: 5000,
enableHighAccuracy: false }).then((resp) => {
//do something
}).catch((error) => {
//can use platform to do platfom specific code here
//@ts-ignore
cordova.plugins.LocationProvider.getOwnPosition({ maximumAge: 3000,
timeout: 5000, enableHighAccuracy: false },(resp)=>{
//do something
}, (error)=>{
//do something
});
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]