Its unclear from the docs if or not _navigator.geolocation.watchPosition_ and _navigator.geolocation.getCurrentPosition_ are working on android. I've followed the instructions but neither seems to work for me.
Yes it is. If you have <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> in your manifest file, it should work.
Hmm, I have that. Maps work, there's even a blue dot for my location. But those 2 api calls don't seem to work. _ navigator.geolocation.getCurrentPosition_ just times out, no matter what time limit i supply, and _navigator.geolocation.watchPosition_ just does nothing.
What happens when you run this:
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 5000
};
function success(pos) {
var crd = pos.coords;
alert(crd.latitude + " " + crd.longitude);
};
function error(err) {
alert('ERROR(' + err.code + '): ' + err.message);
};
navigator.geolocation.getCurrentPosition(success, error, options);
I get 'error' & 'Location request timed out'
Are you running on a real Android device with working GPS sensor or an emulator? If you are running the app on emulator, you must connect to the emulator using telnet and run geo fix 22 44 (or any other coordinate values)
Real device. It even shows my current location when I load a map (with the blue dot). But the API calls simply don't work.
I've partially solved the problem. I stepped though the java code in the debugged and found out that the last position the phone recorded was over 20 hours ago. So the max age limit was preventing getCurrentPosition from returning anything.
Why it doesn't have any gps data for 20 hours is a mystery. Especially as I've view maps since then and they are showing the GPS position perfectly.
Just because position is shown correctly doesn't mean your sensor is working (you may have been at the same position 20 hours ago) Try testing your GPS with sensor test apps on Play Store.
Based on what you say, RN is properly handling the problem. (catching the gps error exception and supplying error info in the JS location callback)
@facebook-github-bot answered
Closing this issue as @satya164 says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.
@npomfret . I am getting exactly the same issue here!
Have you found any solution for it ?
Hi. Still an issue. Thoughts? Thanks!
Most helpful comment
@npomfret . I am getting exactly the same issue here!
Have you found any solution for it ?