huxiaoqiang %!s(int64=4) %!d(string=hai) anos
pai
achega
e04cb0bc7c
Modificáronse 1 ficheiros con 17 adicións e 0 borrados
  1. 17 0
      ios/Runner/AppDelegate.swift

+ 17 - 0
ios/Runner/AppDelegate.swift

@@ -10,4 +10,21 @@ import Flutter
     GeneratedPluginRegistrant.register(with: self)
     return super.application(application, didFinishLaunchingWithOptions: launchOptions)
   }
+  func connectionShouldUseCredentialStorage(_ connection: NSURLConnection) -> Bool {
+          return true
+      }
+
+      func connection(_ connection: NSURLConnection, willSendRequestFor challenge: URLAuthenticationChallenge) {
+          if let previous = challenge.previousFailureCount as? ssize_t {
+              print(String(format: "didReceiveAuthenticationChallenge %@ %zd", challenge.protectionSpace.authenticationMethod, previous))
+          }
+          if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
+              challenge.sender?.use(URLCredential(for: challenge.protectionSpace.serverTrust), for: challenge)
+              challenge.sender?.continueWithoutCredential(for: challenge)
+          }
+      }
+
+      func connection(_ connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: URLProtectionSpace) -> Bool {
+          return protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust
+      }
 }