Double message on ios when get geolocation
Asked Answered
B

1

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?

Bettis answered 22/2, 2018 at 15:54 Comment(5)
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.Grazier
I'd like to add, and possibly if you can get this to work: I started trying out this solution https://mcmap.net/q/1169377/-passing-geolocation-fetched-from-the-app-to-the-uiwebview. 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.Grazier
@Grazier have you found a solution yet? I have not... :(Bettis
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.Grazier
One possible way is described in this #39665867Target
P
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.

Pinkerton answered 11/8, 2022 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.