Skip to content

Instantly share code, notes, and snippets.

@jamigibbs
Last active June 18, 2018 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamigibbs/548fec05761724b674722db60b39bcfb to your computer and use it in GitHub Desktop.
Save jamigibbs/548fec05761724b674722db60b39bcfb to your computer and use it in GitHub Desktop.
Expo Geolocation with emulator check
export const getCurrentLocation = (simulator) => {
return async (dispatch) => {
if (!simulator) {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
dispatch(gotCurrentLocationError('Permission to access location was denied'))
}
let location = await Location.getCurrentPositionAsync({});
dispatch(gotCurrentLocation(location))
} else {
// Demo location for simulator
dispatch(gotCurrentLocation(chicagoFSA))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment