-
Notifications
You must be signed in to change notification settings - Fork 24k
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
On Android, when Location Services is disabled, geolocation.getCurrentPosition returns an error as a string, instead of an object according to spec #11587
Comments
pull request welcome! |
I created pull request #11723. |
Summary: It started with #11587, which reported that the error returned by `getCurrentLocation` did not match the spec. This resulted in PR #11723, which did not get merged because it was said by ide and mkonicek that simply emitting the error will cause it to hang since the `error` callback was never invoked. However, it seems like somewhere along the way PR #13140 got merged in which did exactly that. Since it now matches the spec, turning off location services on Android then running the below example code from [Geolocation](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) docs errors out correctly. ```javascript var options = { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }; function success(pos) { var crd = pos.coords; console.log('Your current po Closes #13306 Differential Revision: D4833377 Pulled By: ericvicenti fbshipit-source-id: dbea5948790a3f521751a0cc0a25f0e323b30667
Summary: It started with facebook#11587, which reported that the error returned by `getCurrentLocation` did not match the spec. This resulted in PR facebook#11723, which did not get merged because it was said by ide and mkonicek that simply emitting the error will cause it to hang since the `error` callback was never invoked. However, it seems like somewhere along the way PR facebook#13140 got merged in which did exactly that. Since it now matches the spec, turning off location services on Android then running the below example code from [Geolocation](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition) docs errors out correctly. ```javascript var options = { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }; function success(pos) { var crd = pos.coords; console.log('Your current po Closes facebook#13306 Differential Revision: D4833377 Pulled By: ericvicenti fbshipit-source-id: dbea5948790a3f521751a0cc0a25f0e323b30667
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
I am using react-native version 0.47.1 and this issue is still there, has not been fixed. Think this might need to be reopened. |
i am using rn v0.48 and this issue is still there.How to fix it ??? |
I'm getting the same issue. error handler is never getting called. the app is hanging. |
I'm using |
same here "react-native": "0.45.1" |
I worked around this using the following: I used a timeout function which runs a fallback location query if X seconds passes. I ensure that this only happens if |
same here "react-native": "0.53.0" |
+1 with react-native: 0.55.4 |
+1 "react-native": "0.54.4", |
you folks do know this is open source and you can open a PR to fix this, right? :) |
I am using react-native: 0.53.3 and the issue still exists. Any workaround? |
fix landed in 0.56.0 version (226bff3), please check. |
Description/Reproduction
Disabling 'Location Services' in Android's system settings, and then calling navigator.geolocation.getCurrentPosition will result in an error, 'No available location provider.', instead of an object, where that's the value of message.
Solution
In LocationModule.java, change this line:
to this, to match the phrasing of the same error from startObserving
Additional Information
The text was updated successfully, but these errors were encountered: