Skip to content

Commit 2b0282a

Browse files
daosefacebook-github-bot
authored andcommitted
facebook#11587 invoke error for getCurrentLocation
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
1 parent b31704b commit 2b0282a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public void getCurrentPosition(
123123
(LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
124124
String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
125125
if (provider == null) {
126-
emitError(PositionError.PERMISSION_DENIED, "No location provider available.");
126+
error.invoke(PositionError.buildError(
127+
PositionError.PERMISSION_DENIED,
128+
"No location provider available."));
127129
return;
128130
}
129131
Location location = locationManager.getLastKnownLocation(provider);

0 commit comments

Comments
 (0)