osx cocoa WKWebview app: Not Load http://

Is there a way to load unsecured sites on WKWebview? (e.g. http://)

I have no issues with SSL sites (https://) but I cannot get unsecured sites to load completely...they only load partially.

It does not matter if I have sandboxing on/off...tried that. Of course just because a site is not secured does not mean it's sinister.


import Cocoa

import WebKit


class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate {


var webView: WKWebView!


override func viewDidLoad() {

super.viewDidLoad()

self.webView.uiDelegate = self

self.webView.navigationDelegate = self

webView.frame = CGRect(x: 0, y: 0, width: 900, height: 500)

view.addSubview(webView)

let url = URL(string: "http://www.internetlivestats.com/total-number-of-websites/")

let request = URLRequest(url: url!)

webView = WKWebView(frame: self.view.bounds)

webView.load(request)

}


}

Try adding this to your Info.plist:


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

Apple by default disables http from apps as a security measure.


You should be able to enable it in your info.plist


See:

https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity/nsallowsarbitraryloads


Be sure to take note of the requirement to justify using http requests if your app is going to be made available through the app store.

osx cocoa WKWebview app: Not Load http://
 
 
Q