AppDelegate.swift 1.4 KB

123456789101112131415161718192021222324252627282930
  1. import UIKit
  2. import Flutter
  3. @UIApplicationMain
  4. @objc class AppDelegate: FlutterAppDelegate {
  5. override func application(
  6. _ application: UIApplication,
  7. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  8. ) -> Bool {
  9. GeneratedPluginRegistrant.register(with: self)
  10. return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  11. }
  12. func connectionShouldUseCredentialStorage(_ connection: NSURLConnection) -> Bool {
  13. return true
  14. }
  15. func connection(_ connection: NSURLConnection, willSendRequestFor challenge: URLAuthenticationChallenge) {
  16. if let previous = challenge.previousFailureCount as? ssize_t {
  17. print(String(format: "didReceiveAuthenticationChallenge %@ %zd", challenge.protectionSpace.authenticationMethod, previous))
  18. }
  19. if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
  20. challenge.sender?.use(URLCredential(for: challenge.protectionSpace.serverTrust), for: challenge)
  21. challenge.sender?.continueWithoutCredential(for: challenge)
  22. }
  23. }
  24. func connection(_ connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: URLProtectionSpace) -> Bool {
  25. return protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust
  26. }
  27. }