I'm building an app using Ionic/Angular/Firebase.
The app requires a user's geolocation.. I'm using Ionic native's geolocation plugin and I'm stumbling on some issues with speed for Android.
On PC it takes less than 500 milliseconds to get the current geolocation.
On iOS it takes about 1 second.
On Android it takes 6+ seconds, and sometimes it even fails entirely.
Is this an issue with Ionic Native? Is there a special plugin for Android?
Here is my code:
this.geolocation.getCurrentPosition({enableHighAccuracy: false, timeout: 3000, maximumAge: 100000}).then((resp) => {
this.userLocation.lat = resp.coords.latitude;
this.userLocation.lng = resp.coords.longitude;
this.getLocation();
}).catch((error) => {
this.geolocation.getCurrentPosition({enableHighAccuracy: true, timeout: 3000, maximumAge: 100000}).then((resp) => {
this.userLocation.lat = resp.coords.latitude;
this.userLocation.lng = resp.coords.longitude;
this.getLocation();
}).catch((error) => {
this.userLocation.lat = this.userData.location.lat || 0;
this.userLocation.lng = this.userData.location.lng || 0;
//if fails, get users last known location.
this.getLocation();
console.log('Error getting location', error);
});
console.log('Error getting location', error);
});
I can't imagine this code is wrong.. As I said, it works wonderfully on PC and iOS.. Is there something I should do if the user is on android? Is there a different plugin I could use? Any help would be amazing!