Created
August 5, 2019 08:41
-
-
Save stepankuzmin/ac5fea7a90d6bbdb0a5096a455d17bf2 to your computer and use it in GitHub Desktop.
XCode iOS WebKit WebView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.swift | |
| // SuperApp-iOS | |
| // | |
| // Created by Stepan Kuzmin on 05/08/2019. | |
| // Copyright © 2019 Stepan Kuzmin. All rights reserved. | |
| // | |
| import UIKit | |
| import WebKit | |
| class ViewController: UIViewController, WKNavigationDelegate { | |
| @IBOutlet weak var webView: WKWebView! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| webView.navigationDelegate = self | |
| let url = URL(string: "http://localhost:3000") | |
| webView.load(URLRequest(url: url!)) | |
| } | |
| // trust self-signed certificates | |
| func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { | |
| let cred = URLCredential(trust: challenge.protectionSpace.serverTrust!) | |
| completionHandler(.useCredential, cred) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment