10

I have created an ios app (Xcode) with a single WebKit View component that loads an external website. This website tries to get the current geolocation with this Javascript: navigator.geolocation.

This all works fine, but the problem is, I get 2 messages:

  1. First a message for the app: 'Allow "NameApp" to access your location while you are using the app?'
  2. Second a message for the webview: 'https://mywebsite.com would like to use your current location'.

I have seen similar questions about this issue, but they all went about a native/offline Cordova app. I have an online app in my Webview.

How can I prevent this double message? Or a workaround for this problem?

angelique000
  • 899
  • 3
  • 10
  • 28
  • I too have this issue and was just about to post a question since the many posts I've seen are years old and not sure if they solve it. I will follow along so I don't post duplicate questions. However, I hope someone gives a solution where the website does not have to be modified, as we are using a 3rd party map service. – RoLYroLLs Apr 13 '18 at 17:41
  • I'd like to add, and possibly if you can get this to work: I started trying out this solution https://stackoverflow.com/a/25053194/286618. The problem is that now the `UIWebView` neither asks for location (which is good) but cannot find my location (which is bad) and I'm not sure the reason. – RoLYroLLs Apr 13 '18 at 17:43
  • @RoLYroLLs have you found a solution yet? I have not... :( – angelique000 Apr 23 '18 at 07:37
  • Nope. So far we noticed: App asks for location 1 time, the the `UIWebView` asks for location. When you navigate away from the `UIWebView` and back, you get asked again. When you navigate away again and back, it does not ask. I've closed the app and tried it again, and I don't get asked. It looks like there might be some cache there which is nice. But after a longer period of time, you get asked again by `UIWebView`. So far we've released as is, but still looking for a solution. – RoLYroLLs Apr 23 '18 at 13:16
  • One possible way is described in this https://stackoverflow.com/questions/39665367/how-to-prevent-wkwebview-to-repeatedly-ask-for-permission-to-access-location/43907448#43907448 – Tarun Lalwani Apr 25 '18 at 16:23

1 Answers1

0

I used the WebViewGold for iOS app template for it & it worked out of the box without second / repeated dialog. Maybe helps other developers/no-code guys.