I'm using this code:
this.watchID = navigator.geolocation.watchPosition((localizacion) => {
console.log("En el enviarPos", localizacion);
}, (err) => {
console.log(err);
}, { enableHighAccuracy: true });
It works in background, but only doesn't work when the phone is locked.
Error:
GeolocationPositionError {code: 3, message: "Timeout expired"}
I was facing same issue but I switched to Geocoder, and it's working fine for me, also it gives lot of info,
=> For Ionic 3
ionic cordova plugin add cordova-plugin-nativegeocoder
npm install --save @ionic-native/native-geocoder@4
=> For Ionic 4
ionic cordova plugin add cordova-plugin-nativegeocoder
npm install --save @ionic-native/native-geocoder