问题
I am loading a https URL in WKWebView and inside that few images are coming from HTTP URL which is loading perfectly fine on enabling NSAllowsArbitraryLoads in info.plist file in iOS 9. But on iOS 10 and above it is not loading the HTTP images. I read Apple and followed all possible way but no luck.
回答1:
Add the below line in info.plist,
NSAllowsArbitraryLoadsInWebContent
and set its value as YES
回答2:
Allowing Insecure Connection to a Single Server
fetching media from an insecure server use below
NSAppTransportSecurity
NSExceptionDomains
"media-server.example.com"
NSExceptionAllowsInsecureHTTPLoads = YES
Apple warnings
Important: Before implementing this exception, consider that a seemingly-benign network request can cause security problems of the sort that ATS is intended to mitigate. For example, fetching media from an insecure server entails the following risks, among others: An attacker can see the media file a user is accessing Your app’s attack surface expands, for example, by allowing a bad actor to feed your app a malicious file intended to trigger a buffer overrun Avoid this connection type if possible.
The App Transport Security (ATS) keys are:
- NSAllowsArbitraryLoads
- NSAllowsArbitraryLoadsForMedia
- NSAllowsArbitraryLoadsInWebContent
- NSExceptionAllowsInsecureHTTPLoads
- NSExceptionMinimumTLSVersion
You can get more info from NSAppTransportSecurity
来源:https://stackoverflow.com/questions/44795126/wkwebview-not-loads-http-image-in-ios-10-and-above