react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

iOS getCurrent position only works on first call, also issues with watchPosition

Open ivosousaa opened this issue 4 years ago • 11 comments

Environment

System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz Memory: 21.92 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.12.0 - /usr/local/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.1 System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 Xcode: 11.1/11A1027 - /usr/bin/xcodebuild npmPackages: react: 16.10.2 => 16.10.2 react-native: 0.61.2 => 0.61.2 npmGlobalPackages: react-native-cli: 2.0.1

Platforms

iOS

Versions

  • Android: --
  • iOS: 12 and 13
  • react-native-geolocation: 2.0.2
  • react-native: 0.61.2 / also had on 0.59.9
  • react: 16.10.2

Description

Hi, I'm getting a problem with getting location on iOS, tested on both iOS 12 and 13, real iPhone 7 and iPhone 8 and 11 Pro in the simulator.

My issue is that getCurrentPosition only works the first time I request it, after that one time it begins timming out on all requests, and watchPosition only works two/three consecutive times, and then stops giving more position changes.

ivosousaa avatar Oct 22 '19 14:10 ivosousaa

Same for me !

gillesBzk avatar Oct 27 '19 18:10 gillesBzk

Same for me, it doesn't work also for iPhone X

gmantovani97 avatar Oct 31 '19 20:10 gmantovani97

The behavior I'm observing in iOS 13.2 simulator

  • Open app in the simulator
  • Get Location
  • Kill app
  • Change location in 'Debug menu'
  • Open App
  • App returns the previous location
  • Kill App
  • Open App
  • App returns correct location

I think it may have something to do with this code here: https://github.com/react-native-community/react-native-geolocation/blob/master/ios/RNCGeolocation.m#L311-L318

scgrossman avatar Nov 03 '19 11:11 scgrossman

@scgrossman Are you passing a maximumAge to the request? Seems like the code will cache the position, by default it's FOREVER! Seems like a ridiculous default.

https://github.com/react-native-community/react-native-geolocation#getcurrentposition

tmaly1980 avatar Dec 07 '19 04:12 tmaly1980

in componentWillUnmount(), don't forget to call Geolocation.stopObserving()

mjm918 avatar Jan 02 '20 11:01 mjm918

still happening for me as well, I set the location for my iOS sim using Debug -> Location -> Custom Location and it does not get picked up, it uses a cached value from somewhere. any fix for this?

amritsub avatar Feb 09 '20 07:02 amritsub

Any updates on this? I think it is a serious issue.

pavermakov avatar Apr 29 '20 09:04 pavermakov

Still relevant

isnifer avatar May 23 '20 15:05 isnifer

any update?

lyseiha avatar Jun 17 '20 14:06 lyseiha

Hi Guys, if you have the When in Use and the Always permission request on iOS, the App for some reason is waiting for the Always permission, so, I deleted the Always Usage Description Key pair in the info.plist because my app doesn't need it and then my app works perfectly.

Good luck!

Arnoldguti avatar Aug 26 '20 15:08 Arnoldguti

This problem is still present and unresolved ...

OleksiiZdaly avatar Mar 21 '24 10:03 OleksiiZdaly