Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.11 KB | None | 0 0
  1.     import UIKit
  2.     import WebKit
  3.  
  4.     class ViewController: UIViewController, WKNavigationDelegate, WKUIDelegate {
  5.         var webView: WKWebView!
  6.        
  7.         override func loadView() {
  8.             let webConfiguration = WKWebViewConfiguration()
  9.             webView = WKWebView(frame: .zero, configuration: webConfiguration)
  10.             webView.uiDelegate = self
  11.             view = webView
  12.         }
  13.        
  14.         func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
  15.             let user = "*****"
  16.             let password = "*****"
  17.             let credential = URLCredential(user: user, password: password, persistence: URLCredential.Persistence.forSession)
  18.             challenge.sender?.use(credential, for: challenge)
  19.         }
  20.        
  21.         override func viewDidLoad() {
  22.             super.viewDidLoad()
  23.             let myURL = URL(string: "http://WebsiteName")!
  24.             let myRequest = URLRequest(url: myURL)
  25.             webView.load(myRequest)
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement