Created
November 11, 2020 17:50
-
-
Save gh-o-st/37571c69c951ac524f107df016d73b02 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const testGeolocation = function() { | |
| if ('permissions' in navigator) { | |
| navigator.permissions.query({name:'geolocation'}).then(function(response) { | |
| if (response.state == 'prompt') { | |
| // do stuff for permission request | |
| } else if (response.state == 'denied') { | |
| // do stuff for permission denied | |
| } else { | |
| // do stuff for permission granted | |
| } | |
| } | |
| } else { | |
| navigator.geolocation.getCurrentPosition( | |
| function(response) { | |
| // do success things | |
| }, | |
| function(response) { | |
| if (response.code == response.PERMISSION_DENIED) { | |
| // do stuff when they deny location | |
| } else { | |
| // do stuff when location fails for other reasons | |
| } | |
| }, | |
| { | |
| maximumAge: Infinity, | |
| timeout:0 | |
| } | |
| ); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment