Post

Replies

Boosts

Views

Activity

Avoiding double location prompt with WKWebView
Hi,I'm brand new to iOS development, and I've written a very simple iOS app that uses a WKWebView to wrap an existing web-based app that needs to access the user's location. It's a route planning app for runners, so accessing the user's current location is quite crucial.It all works fine, and I set an appropriate message in the NSLocationWhenInUseUsageDescription plist entry. However, I get prompted twice for location when I start it up:1. The first prompt contains the NSLocationWhenInUseUsageDescription entry I set, and I can select "Allow whilse using this app"2. The second prompt is a generic Safari location popup that does contain my custom messaging.Of course, this second prompt is pointless after the first one has already been accepted, but I could live with it. However, the App Store review team could not and they rejected the app submission. The reason was the second prompt above (the screenshot they provided demonstrated this), and they suggested I included the NSLocationWhenInUseUsageDescription plist entry (which I already had done...).After searching online I found a solution at https://stackoverflow.com/a/59542677/651972, which works and got rid of the double location prompt. It's a really ugly solution though, as it effectively involves replacing the browser's navigator.geolocation functionality and forwarding any requests to the native app.Is this really the only way to get an WKWebView app that requires location access submitted to the App Store?It seems a really ugly solution for something that I imagine must be quite common, and I'm suspecting I must be missing something simply due to how new I am to iOS development.Thanks,Sam
1
0
3.4k
Feb ’20