WKWebView ask twice for location permission

Viewed 2343

I have a simple iOS Swift App

let url = URL(string: "https://www.mycustompage.com")!
webView.load(URLRequest(url: url))

In Info.plist I allowed all privacy-location permissions.

On https://www.mycustompage.com there is a HTML button which locates the user.

Now I have the problem that my app asks twice for the location permissions. Once for the app and once for the WKWebView.

How can I disable the request for the WebView!?

Thanks

1 Answers

I'm guessing that this is because your webpage is asking for location and safari is basically another app running inside your viewcontroller. One way to bypass this is to simply not ask for the user location in your webpage. instead ask for the user location in the app, then inject then location into your webview with javascript using evaluateJavaScript(_:completionHandler:). Obviously you need to wait until you have both the location and for the page to be full loaded before you make the javascript call.

Related