Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Created February 7, 2016 06:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhrrgn/26e7badfe7a2b392c059 to your computer and use it in GitHub Desktop.
Save dhrrgn/26e7badfe7a2b392c059 to your computer and use it in GitHub Desktop.
// import Setting from React up here
function setHasLocationPermission(hasPerm) {
Settings.set({hasLocationPermission: hasPerm});
}
navigator.geolocation.getCurrentPosition(
(position) => setHasLocationPermission(true),
(error) => {
switch(error.code) {
case error.PERMISSION_DENIED:
setHasLocationPermission(false);
break;
case error.POSITION_UNAVAILABLE:
case error.TIMEOUT:
// Do something here like try again...
break;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment