1

I am calling navigator.geolocation.getCurrentPosition with no troubles. In my web app I have a more user friendly screen that explains the use of the user's location and they press a button to initiate this request. This is all working lovely jubbly.

However, when a user says "always grant this permission" I want to be able to skip this whole process and just get the location automatically. So, is there a way to do something like:

if (!navigator.geolocation.hasPermission)
    navigator.geolocation.getCurrentPosition(etc, etc);
else
    showMyLovelyReasonsWhy();

Thanks in advance!

1 Answers1

1

Seems like you have to make a workaround for this to happen.

Please see: Is there a way of detecting whether a user has already given permission to use navigator.geolocation?

Community
  • 1
  • 1
Matto
  • 108
  • 1
  • 2
  • 13
  • 1
    Thanks Matto, yes this is the same issue and I had considered using a cookie for it. Seems like a little hole in the spec. Thanks for clearing it up though! –  Nov 03 '15 at 11:59
  • Although I've just realised - this solution will store if the permission was given but not distinguishable if the permanent permission is given. So the next time the user visits the site I still cannot tell if they gave it in a permanent manner, so sadly this actually doesn't solve the problem. –  Nov 03 '15 at 12:01
  • You will have to check using the `successCallback` every time. If it passes, the permission was given. You're right about this being a little odd. There should be an easier way :) – Matto Nov 03 '15 at 12:20
  • 1
    It just means I am stuck giving a bad user experience. Either I force them to explicitly press each time, even for frequent visitors; or else request automatically on repeat visitors and (on iPhones it seems) fill their screen with the request. They don't even have a check to permanently remember (iPhone 4S). Poobums. Whine over. Thanks Matto. –  Nov 03 '15 at 12:28