michalchudziak / react-native-geolocation

Geolocation APIs for React Native
MIT License
1.29k stars 224 forks source link

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

Open ivosousaa opened 4 years ago

ivosousaa commented 4 years ago

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

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.

gillesBzk commented 4 years ago

Same for me !

gmantovani97 commented 4 years ago

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

scgrossman commented 4 years ago

The behavior I'm observing in iOS 13.2 simulator

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

tmaly1980 commented 4 years ago

@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

mjm918 commented 4 years ago

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

amritsub commented 4 years ago

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?

pavermakov commented 4 years ago

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

isnifer commented 4 years ago

Still relevant

lyseiha commented 4 years ago

any update?

Arnoldguti commented 4 years ago

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!

OleksiiZdaly commented 5 months ago

This problem is still present and unresolved ...