I'm working on a Hybrid app that uses a WKWebView to display the main UI to the user and which holds all the required functions for data manipulation. I then use the evaluateJavascript
function to access said functions in order to update, change, delete data. This all works fine, except when the device is running iOS 17+. In those instances, we're getting errors on the web console that the functions cannot be found. My assumption is that something has changed with the WKWebView, as the JS code is unchanged. I've dug through release notes but can't see anything that would cause this change in behaviour, anyone else have any ideas?
We had the same issue with iOS 17, we thought that evaluateJavascript()
was not working, and we figured out that the url is not https
but http
.
We did not find it anywhere in docs, but iOS 17 does not support opening http
urls in WKWebView
without having this in info.plist
:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
If your url is http
, put this and it will work normally.
Note, however that allowing HTTP is against Apple recommendations:
You must supply a justification during App Store review if you set the key’s value to YES, as described in Provide Justification for Exceptions. Use this key with caution because it significantly reduces the security of your app. In most cases, it’s better to upgrade your servers to meet the requirements imposed by ATS, or at least to use a narrower exception. (source)
A better solution would be switching the URL to HTTPS.