Skip to content
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

Closed
mwiley opened this issue Dec 21, 2016 · 15 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@mwiley
Copy link

mwiley commented Dec 21, 2016

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
@mwiley mwiley changed the title On Android, when Location Services is disabled, geolocation.getCurrentPosition returns an error as a string, instead of an object accord to spec On Android, when Location Services is disabled, geolocation.getCurrentPosition returns an error as a string, instead of an object according to spec Dec 21, 2016
@brentvatne
Copy link
Collaborator

pull request welcome!

@mwiley
Copy link
Author

mwiley commented Jan 4, 2017

I created pull request #11723.

daose added a commit to daose/react-native that referenced this issue Apr 5, 2017
facebook-github-bot pushed a commit that referenced this issue Apr 5, 2017
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
thotegowda pushed a commit to thotegowda/react-native that referenced this issue May 7, 2017
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
@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

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.

@hramos hramos added the Icebox label Jul 20, 2017
@hramos hramos closed this as completed Jul 20, 2017
@victorbadila
Copy link

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.

@quangtran9kz
Copy link

i am using rn v0.48 and this issue is still there.How to fix it ???

@paulbib
Copy link

paulbib commented Oct 4, 2017

I'm getting the same issue. error handler is never getting called. the app is hanging.

@jamesone
Copy link

jamesone commented Nov 7, 2017

I'm using "react-native": "0.44.0", & this is still occurring.

@choo737
Copy link

choo737 commented Dec 9, 2017

same here "react-native": "0.45.1"

@jamesone
Copy link

jamesone commented Dec 9, 2017

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'

@Schabaani
Copy link

same here "react-native": "0.53.0"

@28harishkumar
Copy link

+1 with react-native: 0.55.4

@tannerhallman
Copy link

tannerhallman commented Jun 20, 2018

+1 "react-native": "0.54.4",

@brentvatne
Copy link
Collaborator

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

@stanshivam
Copy link

I am using react-native: 0.53.3 and the issue still exists. Any workaround?

@dulmandakh
Copy link
Contributor

fix landed in 0.56.0 version (226bff3), please check.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests