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

fix: when using playServices provider the getCurrentPosition error callback is never called #302

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void getCurrentLocationData(ReadableMap options, Callback success, Callba

if (currentActivity == null) {
mSingleLocationCallback = createSingleLocationCallback(success, error);
checkLocationSettings(options, mSingleLocationCallback);
checkLocationSettings(options, mSingleLocationCallback, error);
return;
}

Expand All @@ -63,7 +63,7 @@ public void getCurrentLocationData(ReadableMap options, Callback success, Callba
success.invoke(locationToMap(location));
} else {
mSingleLocationCallback = createSingleLocationCallback(success, error);
checkLocationSettings(options, mSingleLocationCallback);
checkLocationSettings(options, mSingleLocationCallback, error);
}
});
} catch (SecurityException e) {
Expand Down Expand Up @@ -93,7 +93,7 @@ public void onLocationAvailability(LocationAvailability locationAvailability) {
}
};

checkLocationSettings(options, mLocationCallback);
checkLocationSettings(options, mLocationCallback, null);
}

@Override
Expand All @@ -104,7 +104,7 @@ public void stopObserving() {
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
}

private void checkLocationSettings(ReadableMap options, LocationCallback locationCallback) {
private void checkLocationSettings(ReadableMap options, LocationCallback locationCallback, Callback error) {
LocationOptions locationOptions = LocationOptions.fromReactMap(options);
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setInterval(locationOptions.interval);
Expand All @@ -129,6 +129,13 @@ private void checkLocationSettings(ReadableMap options, LocationCallback locatio
requestLocationUpdates(locationRequest, locationCallback);
return;
}

if (error != null) {
error.invoke(
PositionError.buildError(PositionError.POSITION_UNAVAILABLE, "Location not available (FusedLocationProvider/settings).")
);
return;
}
emitError(PositionError.POSITION_UNAVAILABLE, "Location not available (FusedLocationProvider/settings).");
});
}
Expand Down