I am performing Post Request in wkwebview by submitting a form works good when I try to login some social websites as described this question's answer, except Facebook mobile site.
Facebook gives me the error message do no enter your password on sites not located at facebook.com
which maeans facebook is able to detect referrer, may be through the headers sent out.
m.facebook.com needs header value of referrer to be m.facebook.com only
and I am not abe to set the headers in my post call
I tried to modify my request in decidePolicyForNavigationAction
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
let urlString = navigationAction.request.URL!
if(urlString.absoluteString.rangeOfString("https://m.facebook.com/login/?email") != nil){ // which decides it is a post req and is for facebook
let req = navigationAction.request;
webView.navigationDelegate = self
webView.loadRequest(req);
decisionHandler(WKNavigationActionPolicy.Cancel)
}else{
decisionHandler(WKNavigationActionPolicy.Allow)
}
}
then I got to know that this request is not mutable ,so cannot be modified , so I tried it with the mutable copy of it
let req = NSMutableURLRequest(URL: navigationAction.request.URL!)
and this
let req = navigationAction.request.mutableCopy();
instead of
let req = navigationAction.request;
but none of them worked. I asked the same in the comments of the above question (whose link I provided), but no response, is there any work around for this?
If anyone could help me in this, I'll be more then Happy Thanks in advance :)