mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
#11587 invoke error for getCurrentLocation
Summary: It started with https://github.com/facebook/react-native/issues/11587, which reported that the error returned by `getCurrentLocation` did not match the spec. This resulted in PR https://github.com/facebook/react-native/pull/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 https://github.com/facebook/react-native/pull/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 https://github.com/facebook/react-native/pull/13306 Differential Revision: D4833377 Pulled By: ericvicenti fbshipit-source-id: dbea5948790a3f521751a0cc0a25f0e323b30667
This commit is contained in:
parent
b31704bcfb
commit
2b0282aa69
@ -123,7 +123,9 @@ public class LocationModule extends ReactContextBaseJavaModule {
|
||||
(LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
|
||||
if (provider == null) {
|
||||
emitError(PositionError.PERMISSION_DENIED, "No location provider available.");
|
||||
error.invoke(PositionError.buildError(
|
||||
PositionError.PERMISSION_DENIED,
|
||||
"No location provider available."));
|
||||
return;
|
||||
}
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
|
Loading…
x
Reference in New Issue
Block a user