0

I want my app run even app close. or just run when location coordinates changed.

I used appState but it doesnt help me because it works just when appState change.

also I used react-native-background-task but it runs every 7m30s

I use this now but it doesnt help me too. what should I do ?

location(){
  this.watchId = navigator.geolocation.watchPosition(
    (position) => {

      console.log(position.coords.latitude);
       var latitude = position.coords.latitude;
       var longitude = position.coords.longitude;

      this.setState({latitude: latitude, longitude: longitude});
    },
    (error) => this.setState({ error: error.message }),
    { enableHighAccuracy: true, timeout: 200000, maximumAge: 1000},
  );
}

componentDidMount() {
  this.location()
}

componentWillUnmount() {
  navigator.geolocation.clearWatch(this.watchId);
}
rnn
  • 2,393
  • 3
  • 21
  • 39

0 Answers0