In React Native, using expo-location, the gps location refresh rate is too low in iOS

Viewed 1050

I did an app using expo-cli but i'm getting inconsistent results on ios and android, particularly in this part of the code, where i'm excecuting a recurrent code every time i get the GPS position from the phone, especifically the speed.

import * as Location from 'expo-location';
import React from 'react';

class HomeScreen extends React.Component {

  componentDidMount(){
    let watchID = Location.watchPositionAsync(
      {accuracy: 6, timeInterval: 500},
      (position) => {
        // my recurrent code
      }
    );
  }

}

Even as I set it to recover the speed every 0.5 seconds, android phones get it fairly reasonably, once every second or two, but iOS devices do not play so nicely, sometimes waiting up to 30 seconds to update and, for example, the speed jumping +30 mph from one measurement to the next.

Is there any way to increase the GPS refresh ratio in iOS? Maybe is a documented problem i haven't figured out?

"expo": "36.0.0" "expo-location": "~8.0.0" "react": "16.13.1"

1 Answers

Self-answer: In the end it was a bug that still persists in some form inside expo-location: It's required to set the distanceInterval option in the options array of the Location.watchPositionAsync() function:

let watchID = Location.watchPositionAsync(
      { accuracy: 6, timeInterval: 500, distanceInterval: 0 },
      (position) => {
        // my recurrent code
      }
    );
Related