最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - navigator.geolocation.getCurrentPosition no longer working in Safari mobile after iOS9 update - Stack Overflow

programmeradmin1浏览0评论

I have a web app that has this code for getting the user's coordinates:

if (navigator.geolocation) {
   navigator.geolocation.getCurrentPosition(function(position) {  

But the moment I updated to iOS9 it ceased to work. I'm not even getting the Safari prompt anymore asking permission to get my location. Anyone else having this issue after updating to iOS9 and was able to resolve it?

I have a web app that has this code for getting the user's coordinates:

if (navigator.geolocation) {
   navigator.geolocation.getCurrentPosition(function(position) {  

But the moment I updated to iOS9 it ceased to work. I'm not even getting the Safari prompt anymore asking permission to get my location. Anyone else having this issue after updating to iOS9 and was able to resolve it?

Share Improve this question asked Sep 22, 2015 at 15:00 Mark LoganMark Logan 2035 silver badges20 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

I've noticed this myself and i'm wondering if iOS 9 Webkit has started to prevent this working via HTTP as I know Chrome will be preventing this shortly as it currently throws the following alert in the web console.

getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

Try enabling localization in the general settings of iOS. Settings > Localization > Press localization to enable it. And now it works.

It seems that iOS 9 has disabled localization in the settings, after installing.

If you are running on a mac, you'll need to enable location services for safari: enable location on OSX

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论