React-native: On Android, when Location Services is disabled, geolocation.getCurrentPosition returns an error as a string, instead of an object according to spec

Created on 21 Dec 2016  路  15Comments  路  Source: facebook/react-native

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:

error.invoke("No available location provider.");

to this, to match the phrasing of the same error from startObserving

emitError(PositionError.PERMISSION_DENIED, "No location provider available.");

Additional Information

  • React Native version: 0.39
  • Platform: Android
Locked

Most helpful comment

you folks do know this is open source and you can open a PR to fix this, right? :)

All 15 comments

pull request welcome!

I created pull request #11723.

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:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

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 "react-native": "0.44.0", & this is still occurring.

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 Platform.OS === 'android'

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 (https://github.com/facebook/react-native/commit/226bff3ed0772ff3b9d69ea45fb57f3c0c930029), please check.

Was this page helpful?
0 / 5 - 0 ratings