Enabling Geolocation

Hey,

When I try to use the Geolocation, I get:

message: undefined is not an object (evaluating 'RCTLocationObserver.getCurrentPosition')"

It seems that require(‘NativeModules’).LocationObserver returns undefined in Geolocation.ios.js
I did add this to my info.plist:

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!</string>

Am I missing something ?

Thanks!
J

2 thoughts on “Enabling Geolocation

  1. If you are working with Cocoapods, adding RCTGeolocation to the Podfile and then running pod install again should do the trick.

    source 'https://github.com/CocoaPods/Specs.git'
    pod 'React', :path => '../node_modules/react-native', :subspecs => [
      'Core',
      'RCTGeolocation',
      'RCTImage',
      'RCTNetwork',
      'RCTText',
      'RCTWebSocket'
    ]
    

Comments are closed.

Enabling Geolocation

Hey,

When I try to use the Geolocation, I get:

message: undefined is not an object (evaluating 'RCTLocationObserver.getCurrentPosition')"

It seems that require(‘NativeModules’).LocationObserver returns undefined in Geolocation.ios.js
I did add this to my info.plist:

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!</string>

Am I missing something ?

Thanks!
J

1 thought on “Enabling Geolocation

Comments are closed.