Unable to get location information on iOS 16.4 beta 4, iPadOS 16.4 beta 4

I installed iOS16.4 beta4 (iPadOS16.4 beta4) released the other day. After using it, I had two questions, so I will send them as impressions. Previously: In iOS 16.3, a popup appeared twice when retrieving location information for the first installed app. You can get location information by executing the navigator.geolocation.getCurrentPosition method on a web page opened in WKWebView (such as ua_test.html in the attached file). The first time, a pop-up requesting permission for Safari (WKWebView) location information was displayed. The second time, location permissions for the app's domain appeared in a popup with a map. Current situation: In iOS16.4 beta4, the permission request popup for Safari (WKWebView) is not displayed, and only the permission request for the app domain is displayed in a popup with a map. After enabling popups on the map and getting the location, running the navigator.geolocation.getCurrentPosition method does not work and I am unable to get the location. Therefore, I would like to ask the following two questions.

  • How can I show two popups when getting location in 16.4 beta4?
  • From 16.4 beta4, please tell me how to implement permission to get location information in one popup.

Note that the Info:Plist has NSLocationAlwaysAndWhenInUseUsageDescription and describes NSLocationWhenInUseUsageDescription.

Does anyone know about this informetion?

In update 16.4 official version, I also have the same problem

When updating to iOS 16.4, the location function in Line LIFF (WKWebView) will not be available. There should be an authorization prompt, and the relevant location permissions have been confirmed and attempted to be reset, but the issue still cannot be resolved.

safari navigator.geolocation.getcurrentposition not working

Similar questions

Background location updates stop in iOS 16.4

iOS 16.4. Unable to Run in the Background Even with Always Allow Location Permission Enabled

hope Apple will solve it.

I also have the same problem in iOS 16.4. Debug log received looks like “… ** whose view is not in the window hierarchy**” This error occur when both view controllers are presented from another view controller (ViewController A present ViewController B and ViewController A continues present ViewController C).

In here, I used the method “navigator.geolocation.getCurrentPosition” to request location permission but the dialog is not displayed. Then log received is “… ** whose view is not in the window hierarchy**” This happens when the view controller containing the WKWebView is being presented by another view controller => in my opinion, WKWebView has chosen the wrong view controller to display.

I fixed it by using pushViewController instead of using presentViewController. It's just a temporary solution. The main cause seems to be WKWebView (v16.4), hope Apple will solve it.

On my case, replacing presentViewController with pushViewController is not an option as the new VC i'm presenting is a UINavigationController and can't be pushed.

Have you guys managed to overcome this issue? Just came across this issue on v16.4.1 and it looks like it's still occurring.

Hello guys i tried with IOS 16.5 it works great. We have to wait for it. Also, the release date looks like 15. or 16. May ;)

safari navigator.geolocation.getcurrentposition not working

Hi I tried on 16.5 It did not work for me

Apple Event: May 7th at 7 am PT

>  Learn more

>  Add to your calendar 

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Location Permission not working as expected on safari browser

When we are trying to fetch the location in safari browser for my website(which is under development as of now). We are getting popup(allow, don't allow) for location permissions. When i am allowing it is working fine But when i am disallowing first and then change it after going into preferences and change location permission for the website to allow and trying to fetch location for the user again on button click but is not working without reload.

I have tried in console also using this code

navigator.geolocation.getCurrentPosition(

(locationData) => {

console.log(locationData);

(error) => {

console.log(error);

but getting error every-time and not able to get the location without reload.

Expected is it should work without reload if we are giving locations permissions by going to preferences for a website on safari browser.

Posted on Jan 18, 2023 7:20 AM

Similar questions

  • How do I stop getting asked for location permission on the Safari? I found a few answers online but they seemed outdated. I couldn't figure out a way to change Safari's settings to not get asked for location permissions. Any ideas? Thanks in advance. 841 3
  • safari vs location setting hallo, my office requires me to using an apps, but it needs to set the location of safari browser on “always” mode, but i cant find safary on that list (location privacy setting). please let me know how to fix it. 362 1
  • When I try to use Google Maps on my Mac, the map loads and then goes to a flat line. I have location permitted. This issue came up after the last update. When I try to use Google Maps or Weatherbug, the maps are just flat lines. I have location enabled. This happened after the last update. What can I do? 231 4

Loading page content

Page content loaded

There are no replies.

Geolocation position in PWA iOS not resolving

I am trying to get the location of the user in my PWA on iOS (iPhone) - Safari/Chrome

The function is not delivering the location which is a pity, because debugging is a bit hard (I am using toast message - sadly).

I also tried trough

With same results -> nothing.

Does anyone have seen this issue or has been able to obtain current position in iOS PWA succesfully?

Working flawlessly on Android Tablet, and Chrome on PC.

hi @Tommertom , I had same problem with you. This is how I solved it.

  • Make sure you are using the https:// address, (ionic serve/PWA) in http:// will not have permission to get the location access.
  • I check the web ssl certificate information compatibility with apple products, yes they are kinda strict about this, I’ve found they sometimes wouldn’t accept self signed web ssl certificate. if it still not working… (yes, mine is still not working after those two points)
  • Update you Capacitor using v.3 beta (at the time I wrote this).

After that lines, the rest of the (geolocation) code is no need to be changed at all.

I follow a tutorial from here: start-build-deploy-your-first-capacitor3-pwa-with-ionic

hope it helps.

Regards, Martin

Will try and will revert in due course

W3Schools Forum

  • Remember me Not recommended on shared computers

Forgot your password?

getCurrentPosition not working in safari or IE11

By joshmaxwell February 1, 2020 in HTML/XHTML

Recommended Posts

Newbie

joshmaxwell

The file at this url contains exactly the code below, and the domain is SSL   https://staging13.dgstesting.com/new2.html

The problem:   On chrome, edge beta (so basically chrome) and chrome on android, this code will succeed and print your devices latitude to the page. On Safari, safari for ios, and IE11, this will fail with the message "This site does not have permission to use the Geolocation API."

I assume it's not referring to the user granting permission to access location data, but i checked this anyway. Doesn't appear to be the case because it's working in one browser but not another on the same device. In my example, it works in chrome but not ie11 on the same windows 10 computer. I also had a coworker confirm the same thing, it works in chrome but not safari on his mac.

That leaves me thinking it's a domain issue, but why would it work in one browser and not another? After tons of Googling the best answer I can find is that it is an SSL issue, but if you go to   https://developers.google.com/maps/documentation/javascript/geolocation   you can see that even google.com is facing the same issue. So I think that rules that out. you can even try it on w3schools own site   https://www.w3schools.com/html/html5_geolocation.asp

Google of course has no input here because navigator is a product of html5

Link to comment

Share on other sites.

Ingolme

You probably should check the security settings of each of your browsers. Whenever the website makes a request for the location, the browser asks the user for permission. If this is not happening it's likely that the browser has been configured to reject all location permission requests. Each browser has its own permission setting, it is not shared across browsers.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Already have an account? Sign in here.

  • Existing user? Sign In
  • W3Schools.com
  • Online Users
  • Leaderboard
  • All Activity
  • Create New...

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location not working in web browser(Chrome, Safari ) on IOS device such as Iphone, Ipad #387

@joumduk

joumduk commented Jul 7, 2020

@silau2005

silau2005 commented Jul 25, 2020 • edited

Sorry, something went wrong.

@Faisalkc4u

Faisalkc4u commented Aug 4, 2020

@vadrian89

vadrian89 commented Aug 21, 2020

@xpat

xpat commented Sep 4, 2020 • edited

@mma180s

mma180s commented Sep 20, 2020

@stale

stale bot commented Oct 23, 2020

@stale

vadrian89 commented Oct 27, 2020

Stale bot commented nov 29, 2020.

No branches or pull requests

@xpat

  • Skip to main content
  • Skip to search
  • Skip to select language
  • Sign up for free
  • Português (do Brasil)

Geolocation: watchPosition() method

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers .

The watchPosition() method of the Geolocation interface is used to register a handler function that will be called automatically each time the position of the device changes. You can also, optionally, specify an error handling callback function.

A callback function that takes a GeolocationPosition object as an input parameter.

An optional callback function that takes a GeolocationPositionError object as an input parameter.

An optional object that provides configuration options for the location watch. See Geolocation.getCurrentPosition() for more details on possible options.

Return value

An integer ID that identifies the registered handler. The ID can be passed to the Geolocation.clearWatch() to unregister the handler.

Specifications

Browser compatibility.

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

  • Using the Geolocation API
  • The interface it belongs to, Geolocation , and the way to access it — Navigator.geolocation .
  • The opposite operation: Geolocation.clearWatch()
  • A similar method: Geolocation.getCurrentPosition()

safari navigator.geolocation.getcurrentposition not working

Contribute to the Microsoft 365 and Office forum! Click  here  to learn more  💡

April 9, 2024

Contribute to the Microsoft 365 and Office forum!

Click  here  to learn more  💡

  • Search the community and support articles
  • Microsoft 365 and Office
  • Search Community member

Ask a new question

Inactive profile

navigator.geolocation.getCurrentPosition( ) not woking in IOS sharepoint app

we are using navigator.geolocation.getCurrentPosition(locationSuccess, locationError, {timeout: 5000} to get logged in user location details but this is not working insude sharepoint app in IOS. Any suggestions? 

Also is there any way to check if user is logged in through sharepoint app in JavaScript code?

Report abuse

Reported content has been submitted​

Tisky Zheng MSFT

  • Microsoft Agent |

The question you have is mostly related to the customization of the SharePoint app in iOS, I would suggest you post in TechNet Forum which is a specific channel to handle this kind of questions.

Meanwhile, I have found something which may useful: navigator.geolocation.getCurrentPosition not triggering in iOS simulator with React Native .

Disclaimer : Microsoft provides no assurances and/or warranties, implied or otherwise, and is not responsible for the information you receive from the third-party linked sites or any support related to technology.

Thanks for your understanding.

Was this reply helpful? Yes No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

Thanks for your feedback.

Replies (2) 

Question info.

  • For business
  • Norsk Bokmål
  • Ελληνικά
  • Русский
  • עברית
  • العربية
  • ไทย
  • 한국어
  • 中文(简体)
  • 中文(繁體)
  • 日本語

Navigator.geolocation is really slow!

I’m having a minor problem with the navigator.geolocation if statement. In my code, the function always runs through and I don’t experience errors, however it takes about 5-10 seconds every time I refresh the page to grab my longitude and latitude again. Is there a fix to this? Will I just have to live with it?

Is this the same with all browsers? It could also just be the area you live in. Browser geolocation uses a combination of different parameters to suss out your location, and if you live far away from other wifi connections, it could take much longer to get the data the browser needs. You might also check to see that the browser’s location accuracy setting is set to its highest, if that option is available to you. While unlikely, I guess there’s a possibility you’ve written some code that makes the geolocation seem like it’s taking longer than it actually is.

You enable caching of the position data, but I don’t know if that persists through refreshes.

Even when I use the exact code from the example in https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition I get a timeout after the specified 5 secs (using a button with onclick=“getCurrentPosition()”).

If I don’t have a timeout property, it takes 10-20 seconds before returning the position.

I’m in a dense area of the Bay Area with fast internet.

I’ve tried this on chrome, firefox, and safari.

navigator.geolocation works but it’s slow.

Even for the simple Get Geolocation Challenge , when I “run tests” it returns the coordinates after 2 seconds, and if I reload the page and “run tests” again, it takes 33 seconds to show the coordinates!

Has anyone found a way to make navigator.geolocation faster when the the function has already been cached? Anyone else encounter this problem?

You could try caching the previous location in the user’s browser using localStorage so you have something to display sooner:

@lionel-rowe That sounds like a great solution.

However, what happens if the user flies from Hawaii to Alaska, without closing their browser and clearing cache in between? With this localStorage approach, they wouldn’t get the appropriate update to their weather report and location.

:rofl:

Yes, navigator is working very strange lately. I’ve noticed it in codepen so I sent them a note.

You are right that local storage would not work if someone moved somewhere else - it stores stuff in the browser memory.

Another option (besides navigator) is to use an api like ip-api.com - it will figure out your ip and return information, including approximate location (close enough for weather). It would just mean one more AJAX call to get a JSON.

Well, based on the code I posted, they’d see the weather in Hawaii and then the weather in Alaska.

Technically, the code I posted is somewhat flawed, because it contains a race condition (assuming showWeather involves asynchronously calling a weather API). If somehow the second weather API call returned before the first, the user would see the weather in Alaska first and then the weather in Hawaii. I’ll leave fixing that as an exercise for someone else.

Another improvement would be caching the previous weather, plus a timestamp, as well as the previous location. Not only would this remove the race condition, but additionally you could show the user something immediately on page load. It’d look something like this:

Weather for Hawaii Last updated Tue Apr 10 2018 10:15:05 UTC-10 (Pacific/Honolulu) Sunny, 30°C

Then after a few seconds (async getCurrentPosition + async weather API call), it would change to something like this:

Weather for Alaska Last updated Wed Apr 11 2018 10:15:05 UTC-9 (America/Anchorage) Cloudy, 5°C

:clap:

I just noticed that even FCC’s model codepen for this challenge has this issue of loading fast the first time, and slow the other times, unless the browser is refreshed. Your code would definitely be an improvement!

I was tempted to think it’s a corner case. But people usually check the weather once a day, and many people don’t close their browsers every day, so I think your code is a helpful addition!

@kevinSmith That’s good to know you’ve been noticing this too. And interesting to know that it could be codepen’s fault. Thank you!

… I’m curious if lionel-rowe’s response changes your mind about this?

Yes, I didn’t look closely enough at Lionel’s code. He’s right, if it has a location it will load that and then ask for new ones.

He’s right, that should work. Besides the problems he mentions is that sometimes I can’t even get an initial response from navigator. I think there is a big problem with navigator (on codepen I assume) and we don’t know when (or if) it will be fixed. I would suggest using an outside api. Even with that, Lionel’s idea is a good one, improving UX.

I don’t have any problem with geolocation or the weather api. Here is my codepen made 2 yrs ago thats still functional. weather app

At least if there is a small delay in getting the coordinates and weather response you may mask them by some fade in animation or something like that

No matter what free weather api you are going to use, in order to avoid unnecessary calls to the api, I highly recommend in codepen settings->behavior to disable the auto-updating preview that will force codepen to rerun the code each time you make a little change(it can be just a letter changed and voila you have another call to the api).

To also avoid unnecessary calls to the weather api i would just make one call to the api, grab the response, save it in a json var and work with that var until you finish all design and js code then you can switch back to live api calls.

I ran your code. It did stall a bit on a few navigator calls, as much as 10 seconds. But it did eventually return - something I’ve seen it not do. You quota on the weather API is exceeded though (or there is a key problem.)

+1 on disabling auto-updating and on manually caching the AJAX responses in dev.

is it reporting the right location and weather for you?

Location yes. API was getting an error before but is working now.

For further investigation, I wrote a pen to test calls to navigator. It makes a call and tells how long it took, then makes another call.

I was getting delays as much as 20 seconds. It was oddly consistent in being just short of 20 seconds, especially once it got going. When I exported it and ran it locally, I got the same result. That was with chrome so I thought I’d try it with firefox. I got delays again, but now around 4 seconds max.

I’m guessing that the browsers have some kind of internal throttling an multiple calls to navigator. The first few calls are often fast, but later once seem to hover just shy of that browser defined upper limit.

In Javascript there is already available a method for “ watching ” the position without the need to make several calls to navigator.geolocation.getCurrentPosition . The method is called watchPosition , and I made this pen for you to have a look if you’re interested. Careful, because the timeout is set to 5 seconds, so it refreshes its position every 5 seconds.

Hope it’s helpful.

Happy coding!

:smiley:

After quitting Chrome and loading your watchPosition page again, it worked. Thanks for pointing out that method!

:slight_smile:

Yes, watchPosition is useful, but I think you missed the point. The point wasn’t to find the best way to have an app regularly update positions. The point was to show how getCurrentPosition starts out fast and then slows to a slow (seemingly browser throttled) speed on subsequent calls - something that happens in development a lot.

Also, your pen doesn’t work for me - it keeps timing out.

PS - What part of Spain are you in? My wife and I are hoping to move to Barcelona in the next few years.

Yes, navigator.geolocation has been working incredibly quickly for me on the phone too, with all the tests I’ve done on various code’s using the navigator.geolocation method.

Just wanted to add a note to say that the above line doesn’t work. Possibly because pos.coords is a complex object that can’t be stringified… it just returns an empty {}

I had to change it to

And then I was able to save them to localStorage

Siderite's Blog

Some features of this website do not work as expected when JavaScript is disabled

navigator.geolocation API strange behaviour on Microsoft Edge - a foolproof location snippet in Javascript

  • programming

May 9, 2018

safari navigator.geolocation.getcurrentposition not working

What do you mean? The solution is above, by using a timeout. I wrote this article a while ago, though. I expected things to have changed.

Saravana Kumar Narayanan

I am also facing the same issue, IE and Edge making our life harder. I am not able to find solution for the above.

Post a comment

Enable JavaScript to post comments on this blog.

IMAGES

  1. Geolocation navigator.geolocation.getCurrentPosition ( function

    safari navigator.geolocation.getcurrentposition not working

  2. [Solved] navigator.geolocation.getCurrentPosition doesn't

    safari navigator.geolocation.getcurrentposition not working

  3. How to use the Geolocation API

    safari navigator.geolocation.getcurrentposition not working

  4. HTML : navigator.geolocation.getCurrentPosition returning wrong results

    safari navigator.geolocation.getcurrentposition not working

  5. bug: Geolocation.getCurrentPosition throws error on new permission

    safari navigator.geolocation.getcurrentposition not working

  6. [javascript] navigator.geolocation.getCurrentPositionでタイムアウトの解決方法

    safari navigator.geolocation.getcurrentposition not working

VIDEO

  1. Get Exact User Location using JavaScript

  2. Safari Rally Drivers Worried About The Rains

  3. Mammito tries to be the navigator at the WRC safari rally 2024 experience

  4. Big Boost For The WRC Safari Rally:Safaricom to offer connectivity services

  5. how to clear safari history on iphone iOS17

  6. The only regret is the path not taken

COMMENTS

  1. geolocation.getCurrentPosition on Safari on iOS

    Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

  2. Unable to get location information…

    You can get location information by executing the navigator.geolocation.getCurrentPosition method on a web page opened in WKWebView (such as ua_test.html in the attached file). The first time, a pop-up requesting permission for Safari (WKWebView) location information was displayed. The second time, location permissions for the app's domain ...

  3. Geolocation: getCurrentPosition() method

    The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available. enableHighAccuracy Optional. A boolean value that indicates the application would like to receive the best possible results. If true and if the device is able to provide a more accurate position, it will do so.

  4. Geolocation not working on Safari desktops

    I'm using navigator.geolocation.getCurrentPosition. All hardware location settings are enabled. Any help is hightly appreciated. Show more Less. iMac ... Safari 11.1 Geo location not working I've noticed recently that Mac OS Safari 11.1 (desktop) is no longer able to retrieve the lat/long location of the user. This works fine in Firefox for Mac ...

  5. geolocation service not working on safari 14.0 on mac #14334

    Saved searches Use saved searches to filter your results more quickly

  6. Location Permission not working as expect…

    navigator.geolocation.getCurrentPosition((locationData) => {console.log(locationData);}, ... I couldn't figure out a way to change Safari's settings to not get asked for location permissions. ... Location Permission not working as expected on safari browser.

  7. Using the Geolocation API

    Using the Geolocation API. Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers. The Geolocation API is used to retrieve the user's location, so that it can for example be used to display their position using a mapping API. This article explains the basics of how to use it.

  8. Geolocation position in PWA iOS not resolving

    Tommertom January 7, 2021, 6:50pm 1. Hi. I am trying to get the location of the user in my PWA on iOS (iPhone) - Safari/Chrome. const position = await Plugins.Geolocation.getCurrentPosition(); The function is not delivering the location which is a pity, because debugging is a bit hard (I am using toast message - sadly). I also tried trough.

  9. getCurrentPosition not working in safari or IE11

    On Safari, safari for ios, and IE11, this will fail with the message "This site does not have permission to use the Geolocation API." I assume it's not referring to the user granting permission to access location data, but i checked this anyway. Doesn't appear to be the case because it's working in one browser but not another on the same device.

  10. Location not working in web browser (Chrome, Safari ) on IOS device

    They do not work in iOS Safari. Directly calling the "await location.getLocation()" will give intended behavior but only lat & long will be available as browser API also only returns those 2 values. I can confirm this worked for me aswell.

  11. Geolocation: watchPosition() method

    See Geolocation.getCurrentPosition() for more details on possible options. ... The interface it belongs to, Geolocation, and the way to access it — Navigator.geolocation. The opposite operation: Geolocation.clearWatch() A similar method: Geolocation.getCurrentPosition() Help improve MDN

  12. navigator.geolocation.getCurrentPosition( ) not woking in IOS

    The question you have is mostly related to the customization of the SharePoint app in iOS, I would suggest you post in TechNet Forum which is a specific channel to handle this kind of questions. Meanwhile, I have found something which may useful: navigator.geolocation.getCurrentPosition not triggering in iOS simulator with React Native.

  13. javascript

    Im trying to implement the geolocation services to get the latitude and longitude values, but in Safari it just doesnt work. And then in firefox it works, but it doesnt know how to handle errors. I have no idea why.

  14. Navigator.geolocation is really slow!

    With this localStorage approach, they wouldn't get the appropriate update to their weather report and location. navigator.geolocation does work fast the first time the code runs and slow each time after. All I need to do to get that "first-time" speed, is to restart the browser. But I can't tell the user to do that.

  15. navigator.getCurrentPosition() not working in Firefox nor Safari

    1. I can't seem to get navigator.getLocation () working on either Firefox 65 or Safari 10. console.warn('Cannot load user location. Make sure you gave permission to share location'); navigator.geolocation.getCurrentPosition(function (position) {. lat0 = position.coords.latitude; long0 = position.coords.longitude;

  16. navigator.geolocation API strange behaviour on Microsoft Edge

    Today we tested a web application in the new Microsoft Edge browser. To our surprize, the site failed where Internet Explorer, Chrome, Firefox and even Safari worked perfectly well. I narrowed the problem to the navigator.geolocation.getCurrentLocation which wasn't working.

  17. Getting a device's precise position using the browser geolocation API

    I tried to track the user's altitude with the geolocation API, but using watchPosition to keep track of the user's position does not update the values frequently enough for me to track the users altitude precisely enough.