-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS]Only able to obtain the location immediately when the app starts #300
Comments
I did some more testing and found that it seemed to be watchPosition, and once the app ran watchPosition listener, getCurrentPosition no longer return the coords, but always return an error 'Unable to fetch location within xxx s'. I've removed the use of watchPosition from the code, and now getCurrentPosition immediately gets the coordinates every time. This also explains why my App was still getting coordinates 2 days ago, because I just added the watchPosition code yesterday, trying to make the update more timely, but I couldn't get coordinates anymore... It took me more than a day to find the cause, but I should have thought it was the watchPosition problem earlier. I don't know why, but it seems like the problem is solved, and I'll do more testing, Don't use watchPosition and getCurrentPosition together, hopefully to help someone else with the same problem. |
@YaoHuiJi were you using getCurrentPosition and WatchPosition in the same component? Or are you saying you cant use them together in the same app or in the same stack.. im facing the same issue and my current implementation consists of a custom hook that executes getCurrentLocation or watchPosition depending of the needs of the screen, but im never using both methods on the same instance of the hook or the component that calls it. |
In my case, getCurrentPosition can't return coords if watchPosition is listening. So I remove the watchPosition and use setInterval+getCurrentPosition to update coords regularly. Everything works fine now. |
Ok, so im guessing my cleanup methods which clear the watch are probably not working as expected.. thanks! |
Thanks for reporting. Please try version |
finally, but thanks for getting it sorted and replied after 6 months |
I encountered a strange problem that has left me very confused. My app is only able to get coordinates once through "watchPosition" when it starts up, and the retrieval speed is very fast (the small arrow icon at the status bar indicating location retrieval briefly turns blue and solid ). However, afterwards, it fails to retrieve the address again, whether through watchPosition or getCurrentPosition, and I no longer see the location icon in the status bar turning solid, it remains a hollow/outline icon
However, in the following scenarios, it is able to retrieve coordinates once again, but only once:
I suspect it may be related to the cellular or GPS signals on my phone. However, after testing various settings, such as enabling/disabling high accuracy or adjusting timeout settings, the problem persists. Additionally, other geo apps, such as Apple's Map or Reminder apps, or other map apps are able to obtain the correct location.
It looks like watchPosition and getCurrentPosition only get the address once when the application starts, and then never again, and each failed attempt results in the following error:
The info.plist:
I'm out of my mind😫. I have no idea what's going on. Can someone give me some ideas? Any thought possible.
The text was updated successfully, but these errors were encountered: