Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created August 5, 2019 08:41
Show Gist options
  • Save stepankuzmin/ac5fea7a90d6bbdb0a5096a455d17bf2 to your computer and use it in GitHub Desktop.
Save stepankuzmin/ac5fea7a90d6bbdb0a5096a455d17bf2 to your computer and use it in GitHub Desktop.
XCode iOS WebKit WebView
//
// 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