Last active
May 24, 2020 20:53
-
-
Save jinal90/ce8b737a3f7b6c6b20e432a8948688a2 to your computer and use it in GitHub Desktop.
Code snippet to demonstrate URLSessionDelegate
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
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