Here is my solution:
You will need use:
Platform: https://ionicframework.com/docs/api/platform/Platform/
Diagnostic: https://ionicframework.com/docs/native/diagnostic/
Geolocation: https://ionicframework.com/docs/native/geolocation/
Location Accuracy: https://ionicframework.com/docs/native/location-accuracy/
getUserPosition() {
const HIGH_ACCURACY = 'high_accuracy''
if (this.platform.is('cordova')) {
this.diagnostic.isLocationEnabled().then(enabled => {
if (enabled) {
this.diagnostic.getLocationMode().then(locationMode => {
if (locationMode === HIGH_ACCURACY) {
this.geolocation.getCurrentPosition().then((position) => {
// populate my data
});
} else {
this.askForHighAccuracy();
}
});
} else {
// handle if user deny location
}
});
}
}
askForHighAccuracy() {
this.locationAccuracy
.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(()
=> {
this.geolocation.getCurrentPosition().then((position) => {
// populate my data
});
});
}
After this I need that the user set the High Accuracy mode and accept google
terms to use.
Hope it work for you guys =)
[ Full content available at:
https://github.com/apache/cordova-plugin-geolocation/issues/114 ]
This message was relayed via gitbox.apache.org for [email protected]