Tuesday, April 2, 2024
HomeiOS Developmentjavascript - Why is Chrome iOS sending immediate when geolocation is granted

javascript – Why is Chrome iOS sending immediate when geolocation is granted


I wish to enable geolocation in some sections of my web site, to take action I choose to ask for permission on the consumer web page earlier than prompting them with the browser geolocation permission request.

So I collect the response.state with one thing like the next…

navigator.permissions.question({ identify: "geolocation" }).then((response) => {
  // do stuff with response.state
});

After which if the state is immediate I will simply render one other web page asking them properly to permit geolocation by clicking on a button. This button triggers this code

navigator.geolocation.getCurrentPosition(
  (place) => {
    if (place) {
      // location was granted for positive, we do stuff
    }
  },
  () => {
    // this implies the consumer did not settle for geolocation
  }
);

It really works completely on my pc, in all browsers. Nevertheless, when refreshing the web page on Chrome iOS after permitting geolocation, it is nonetheless on immediate when the state ought to be granted; I can really get the precise place regardless of the state being immediate which makes little or no sense to me.

What is going on right here with Chrome iOS? Is there a workaround? The habits is completely different however I can not pinpoint why, and might’t discover documentation about it. This improved UX is important. I may simply immediate it and ask for the perfect however I need the consumer to approve first.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments