Skip to content

Enabling Geolocation #197

Closed
Closed

Description

@jnak

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

Activity

  1. vjeux commented on Mar 25, 2015

    @vjeux
    Contributor

    This is a bug on our end, the native module must not have been linked to the xcode project. @a2 can you help?

  2. a2 commented on Mar 25, 2015

    @a2
    Contributor

    Is this in an example project or in an app you're working on?

  3. jnak commented on Mar 25, 2015

    @jnak
    Author

    Ah ok! I was trying this from the Movies app. How can I help ?

  4. a2 commented on Mar 25, 2015

    @a2
    Contributor

    I'll take a look now! 😺

  5. a2 commented on Mar 25, 2015

    @a2
    Contributor

    Oh, I see what you mean. Here's what you have to do:

    1. Drag RCTGeolocation.xcodeproj into the Libraries folder.
    2. Click on the Movies project in the project navigator.
    3. Click Movies under TARGETS.
    4. Click the Build Phases tab.
    5. In the Link Binary With Libraries phase, click the plus icon and select libRCTGeolocation.a from the modal list that appears.

    That should be all you need. Let me know if that works for you. 😸

  6. jnak commented on Mar 25, 2015

    @jnak
    Author

    AWESOME!

    I didn't realized I had to link libs manually. I don't think it's in the docs. If no one is working on it to the docs, I'm happy to add it this weekend :)

    Let me know!

  7. everystone commented on Nov 7, 2015

    @everystone

    What about when developing for Android on Windows?

  8. naoisegolden commented on Dec 10, 2015

    @naoisegolden

    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'
    ]
    
  9. mikelambert commented on May 11, 2016

    @mikelambert
    Contributor

    Why was there is no mention of any of this on https://facebook.github.io/react-native/docs/geolocation.html ? :(

  10. mobilesite commented on Jun 28, 2016

    @mobilesite

    @naoisegolden I also got this error and i'm using pod too, but i can't fix this bug with the method you reminded. When I use pod search RCTGeolocation to search it, nothing can be find in the repos. Could you do me a favor to analyze about it? Thank you very much!

  11. smokinjoe commented on Oct 27, 2016

    @smokinjoe

    @a2 is there a solution for Xcode 7.3.1? I was able to follow until selecting the library. I don't have libRCTGeolocation.a available.
    screen shot 2016-10-27 at 10 53 48 am

  12. locked as resolved and limited conversation to collaborators on May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions