3

I want to open authorised url in WKWebview my application. I have tried all possible solution from stackoverflow and google but none of them working for me.


        if let url = myURL {
            var request = URLRequest(url: url)
            request.addValue("3d66fc991e82415398a8e92d8856da3e", forHTTPHeaderField: "Authorization")
            webView.load(request)
        }

I have also added this delegate.

 public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {

        let creds = URLCredential(user:"user1", password:"1234", persistence: URLCredential.Persistence.permanent)
        completionHandler(URLSession.AuthChallengeDisposition.useCredential, creds)
    }
shraddha11
  • 783
  • 4
  • 17

0 Answers0