A web view with POST data does not POST the body, so I'm missing required parameters of the web view. It works fine in later versions, but does not work with 9.1.
Here is how I'm setting up my webview:
lazy var webView:WKWebView = {
let view = WKWebView()
let url:URL = URL(string:<MyURL>)!
let body:String = String(format: "param1=%@¶m2=%@", arguments: [getParam1(), getParam2()])
var request = URLRequest(url:url)
request.httpMethod = "POST"
request.httpBody = body.data(using: .utf8)
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
view.navigationDelegate = self
view.load(request)
view.backgroundColor = .white
view.scrollView.delegate = self;
return view
}()
I've confirmed that my parameters exist when I create body
. I get to the page, but it displays an error message about both parameters missing.
Any idea how I can get this working with older versions?
Edit: When I add a breakpoint at the line view.navigationDlegate...
and then print the description of the request, I notice requests from later and earlier versions are the same except for some expected bytes which change due to the session token on the device. The range is the exact range I would expect to differ.