TypeError: undefined is not an object (evaluating 'navigator.geolocation.requestAuthorization')

geolocation has been extracted from react native .60 version. If you need an alternative solution

install react-native-community/geolocation

npm install @react-native-community/geolocation --save


react-native link @react-native-community/geolocation

then

IOS

You need to include the NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation when using the app. In order to enable geolocation in the background, you need to include the 'NSLocationAlwaysUsageDescription' key in Info.plist and add location as a background mode in the 'Capabilities' tab in Xcode.

Android

To request access to location, you need to add the following line to your app's AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

usage

import Geolocation from '@react-native-community/geolocation';

Geolocation.getCurrentPosition(info => console.log(info));