0

WKWebView doesn't load http requests, only https is working. My Url's strings are fetched from an API, so the url's links could be http and https. I did read about security, however the only thing I found was to add the following lines to the Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key> NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

However, in the .plist these keys don't exist. Is there any way to make WKWebView load http web content, and would the app be approved by the App Store?

I'm using Xcode 9.

0

2 Answers 2

2

1: Open your info.plist file from the project

2: add App Transport Security Settings in Information Property List

3: add Allow Arbitrary Loads in App Transport Security Settings

See the attached images

enter image description here

enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

How to load HTTP content in WKWebView and UIWebView: hackingwithswift.com/example-code/wkwebview/…
1

You can ignore all transport security restrictions with the key your provided using the following:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

I assume your example is not working due the space in the key:

<key> NSAllowsArbitraryLoadsInWebContent</key>

Try to use the same value as you did but without the space.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.