Geolocation in React Native iOS
<p>I am trying to access navigator.geolocation in my application.</p>

<p>I have also set "NSLocationWhenInUseUsageDescription" in my info.plist.</p>

<p>But, when I run my app, It throws an error saying "undefined is not an object (evaluating navigator.geolocation.getCurrentPosition)" .</p>

<p>Here is my code - </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { Component } from 'react';
import {
  AppRegistry,
  Image,
  ListView,
  StyleSheet,
  Text,
  Navigator,
  TouchableHighlight,
  Alert,
  TouchableOpacity,
  View
} from 'react-native';
import Spinner from 'react-native-loading-spinner-overlay'
var GiftedSpinner = require('react-native-gifted-spinner');
var GLOBAL = require('./Globals');
var stateName;
var latitude;
var longitude;

class PersonByLocationPage extends Component {

  constructor(props) {
    super(props);
    this.data = this.props.data;

     navigator.geolocation.getCurrentPosition(
                        (position) =&gt; {
                           var crd = position.coords;
                           latitude = crd.latitude;
                           longitude = crd.longitude;
                            // alert(latitude);
                            // alert(longitude);
                          },
                          (error) =&gt; alert(error.message),
                          {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
                      );


    this.REQUEST_URL = 'sample';


    this.state = {
      dataSource: new ListView.DataSource({
        rowHasChanged: (row1, row2) =&gt; row1 !== row2,
      }),
      loaded: false,
      networkError: false,
    };
  }</code></pre>
</div>
</div>
</p>

<p>Can anybody tell what I am doing wrong ?</p>