Advertisement
Guest User

Untitled

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