Native geolocation ionic watch position working on background but not when phone is locked

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"}

Upvotes: 0

Views: 620

Answers (1)

Deepak Kumar
Deepak Kumar

Reputation: 114

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

Upvotes: 0

Related Questions