Skip to content

Instantly share code, notes, and snippets.

@jinal90
Last active May 24, 2020 20:53
Show Gist options
  • Save jinal90/ce8b737a3f7b6c6b20e432a8948688a2 to your computer and use it in GitHub Desktop.
Save jinal90/ce8b737a3f7b6c6b20e432a8948688a2 to your computer and use it in GitHub Desktop.
Code snippet to demonstrate URLSessionDelegate
class MyViewController: UIViewController, URLSessionDelegate {
//
// MARK: - Constants
//
let pinnedCertificates: [Data] = {
let url = Bundle.main.url(forResource: "certificate_name", withExtension: "der")!
let data = try! Data(contentsOf: url)
return [data]
}()
// ..
// ViewController class implementation
// ..
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
// Empty delegate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment