Last active
June 18, 2018 18:37
-
-
Save jamigibbs/548fec05761724b674722db60b39bcfb to your computer and use it in GitHub Desktop.
Expo Geolocation with emulator check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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