title: Retrieving geolocation with React Native
body: <p>I'm trying to get a user's location coordinates in React Native from their iPhone, but when I follow Facebook's Geolocation setup, it isn't returning a response with that user's data (<a href="https://facebook.github.io/react-native/docs/geolocation.html#content" rel="noreferrer">https://facebook.github.io/react-native/docs/geolocation.html#content</a>). I'm not sure if there's an issue with the code (my GeoLocation component's code is below). I'm also testing through the iOS simulator - so not sure if pulling geolocation only works through an actual device or if the simulator can use your location based on wifi.</p>
  
  <p>If this the correct way to find user location or is there a better way in react native?</p>
  
  <p>Thanks - any and all help is greatly appreciated!</p>
  
  <pre><code>const React = require('react-native');
  
  const {
    StyleSheet,
    Text,
    View,
  } = React;
  
  exports.framework = 'React';
  exports.title = 'Geolocation';
  exports.description = 'Examples of using the Geolocation API.';
  
  exports.examples = [
    {
      title: 'navigator.geolocation',
      render: function(): ReactElement {
        return &lt;GeolocationExample /&gt;;
      },
    }
  ];
  
  const GeolocationExample = React.createClass({
    watchID: (null: ?number),
  
    getInitialState: function() {
      return {
        initialPosition: 'Can\'t find',
        lastPosition: 'Can\'t find',
      };
    },
  
    componentDidMount: function() {
      navigator.geolocation.getCurrentPosition(
        (initialPosition) =&gt; this.setState({initialPosition}),
        (error) =&gt; alert(error.message),
        {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
      );
      this.watchID = navigator.geolocation.watchPosition((lastPosition) =&gt; {
        this.setState({lastPosition});
      });
    },
  
    componentWillUnmount: function() {
      navigator.geolocation.clearWatch(this.watchID);
    },
  
    render: function() {
      return (
        &lt;View&gt;
          &lt;Text&gt;
            &lt;Text style={styles.title}&gt;Initial position: &lt;/Text&gt;
            {JSON.stringify(this.state.initialPosition)}
          &lt;/Text&gt;
          &lt;Text&gt;
            &lt;Text style={styles.title}&gt;Current position: &lt;/Text&gt;
            {JSON.stringify(this.state.lastPosition)}
          &lt;/Text&gt;
        &lt;/View&gt;
      );
    }
  });
  
  const styles = StyleSheet.create({
    title: {
      fontWeight: '500',
    },
  });
  
  module.exports = GeolocationExample;
  </code></pre>