Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does React Native navigator.geolocation.watchPosition run in background?

I have the following code and wonder if it runs when the app is in the background for both iOS and Android and also web app:

var id = navigator.geolocation.watchPosition(success, error, options);
like image 727
FullStack Avatar asked Jul 04 '16 19:07

FullStack


People also ask

Can you track background geolocation With react-native?

Access the device GPS every 10 seconds even when the app is killed— The React-Native Geolocation Library kept timing out after every 30–45 seconds after the app was killed.

How do you check location is on or off in react-native?

how can I check location condition before using geolocation ? @LwinKyawMyat you can check it in componentDidMount() and onSuccess you can use geoLocation for fetching location.

What is navigator geolocation?

The Navigator geolocation property is used to return a geolocation object by the browser which can be used to locate a user's position. It is a read-only property and is only available on the approval of the user since it can compromise the user's privacy.


2 Answers

It does run when the app is in the background for iOS and Android not for web app, and not when the app is not running.

like image 119
scott dickerson Avatar answered Sep 20 '22 09:09

scott dickerson


See this link for a complete guide on how to do geolocation with react-native https://blog.expo.io/a-complete-guide-to-recording-location-data-in-react-native-9ee6e1ef7893.

Basically what it is saying is that you can do geolocation tracking in the background but only if you use native code or a framework that does that, not with the react-native wrappers or expo.

like image 25
Hinrich Avatar answered Sep 20 '22 09:09

Hinrich